Francois PIETTE wrote:
> Before D2009, the user will have to add code to encode their
> international characters in UTF8 and the component will have to have
> code to handle it properly.
> In the component code, you'll have conditional compilation for
> handling string properties which have a need for international
> charset. 

Use of a type alias would avoid conditional compilation by one 
declaration "UnicodeString = WideString" for pre-D2009 compilers.
The components and user applications would the become 100% compatible
from D7 to D2009. 

> For example a filename in the FTP component. Assuming FTP
> protocol want UTF8 string, then when compiled with D2009 and up, the
> component will convert unicode string (UTF-16) to UTF-8 before
> sending down to the wire. When compiled with pre-D2009, the component
> will simply takes the string as an UTF-8 string and send it as is.

Don't forget file system API functions they have to be called with
a PWideChar path or file name argument anyway, so the UTF-8 string 
always has to be converted to WideString first which would add plenty
of IFDEFs, making the code less readable. Those conversions are not
required if we used WideString from the beginning.
> At the application level, let's assume the application has a TEdit to
> enter a file name. With D2009 and up, there is nothing to do, just
> pas the text value (UTF-16 !) to the component. With pre-D2009, the
> application developer will need to use a unicode enabled TEdit (not
> provided with Delphi !), convert the text value to UTF-8 and feed the
> FTP component property with it.

Even in D7 you can assign a WideString to, for instance, a TEdit.Txt, 
the conversion is done in the background using current default system
code page. Of course characters that cannot be converted will be shown
as "?". However if you use, for instance the TNT Unicode controls 
even Chinese file names are displayed properly.  
> Isn't it too simple ? Did I miss something ?

I think it is more complicated, no clean solution and confusing.

Arno Garrels
To unsubscribe or change your settings for TWSocket mailing list
please goto
Visit our website at

Reply via email to