RTC Forums
May 24, 2022, 05:10:53 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: RTC is not unicode ?  (Read 2704 times)
chmichael
Newbie
*
Posts: 5


« on: November 19, 2009, 01:49:11 AM »

As i can see that RTC is using AnsiStrings instead of Strings ...

Converting AnsiString to String will make it Unicode on Delphi 2009/2010 and Ansi on previous version of Delphi.

Thank you
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1870


« Reply #1 on: November 19, 2009, 03:05:52 AM »

RTC SDK uses Unicode only where it makes sense to do so. What you need to understand is that each Unicode character is 16 bits long (2 bytes), which makes Unicode strings useless for sending or receiving plain binary data, so that most general-purpose Read and Write methods and properties in the RTC SDK have to use the AnsiString type.

Depending on what type of content you are receiving (read) and sending (write), you will want to use different encoding and decoding functions when working with Unicode strings. For example, if you are sending or receiving HTML or XML files, you might want to use HTML or UTF-8 or UTF-16 encoding and decoding. But the encoding and decoding decision is left entirely up to the developer (you), because the RTC SDK can NOT know what kind of content you are sending out. And it should NOT know and should NOT care. For the RTC SDK, all the data sent and received is "binary". And what you do NOT want in any case is some magical conversion done "under the hood", just so you can assign a Unicode string to a method or a property, but at the end do not know what will really come out.

But, methods and properties where automatic conversion does make sense (for example the "asText" type for RTC Remote Functions, which has always been for sending UTF-8 encoded text) now fully supports the use of Unicode strings directly, since conversion to and from plain binary data can there be handled automatically and transparently on the Server and the Client side by the RTC SDK.

In other words, if you see a property or method in the RTC SDK which accepts the "String" type, you can rest assured that all the conversions to and from Unicode will be handled automatically for you. For all the other methods and properties where AnsiString or RtcString is being accepted, you are either supposed to use the AnsiString type (because it is binary data), or use the appropriate conversion functions (for example: URL_Encode/URL_Decode, Utf8Encode/Utf8Decode, and so on).

Best Regards,
Danijel Tkalcec
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.022 seconds with 16 queries.