RTC Forums

Subscription => Support => Topic started by: chmichael on November 19, 2009, 01:49:11 AM

Title: RTC is not unicode ?
Post by: chmichael 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

Title: Re: RTC is not unicode ?
Post by: D.Tkalcec (RTC) 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