[fpc-devel] Unicode and UTF8String

Luiz Americo Pereira Camara pascalive at bol.com.br
Tue Dec 2 00:01:26 CET 2008


Felipe Monteiro de Carvalho escreveu:
> I think it's the other way around. If you know what encoding is
> expected you have a more predictable result. You know where a
> conversion will take place. For example:
>
> MyUTF8String := MyRTLString;
>
> So we get an error that characters are being lost, but only in Windows
> ... ummm, it turns out there was a problem with the conversion routine
> in the RTL.
>   

Will not get lost. UTF8 holds all unicode range. It will be converted 
from UTF-16 to UTF 8
>   
>> To be honest, I think a case for LCL follows widget set encoding could also
>> be made.
>>     
>
> It was already investigated that the conversion time is negletible
> compared to the paint time.
>
> Using RTLString increases the problems for developers, because they
> need to identify when they need to do something which require knowing
> the encoding and increases the size of the code to add the conversion.
>   

Not necessarily, the compiler would select the adequate conversion or 
not convert. Says you have a function that expects a UTF8 encoding and 
you set that parameter as UTF8String. Just do MyUTF8 := MyRTLString. 
Automatically in windows you get a conversion, under unix no.

> Remember that we are expecting to build software in a RAD way.
>
> So in one hand you have no substantial gain and in the other some annoyance

Initially i'm not in favor of using RTLString, IMO LCL should choose an 
encoding UTF16 or UTF8 and then let the compiler convert only the system 
calls.

Here's the conversions we would got:

LCL as UTF8

OS-WidgetSet                   Conversion LCL <-> WidgetSet     
Conversion LCL <-> System calls
-----------------                ---------------------------------     
-----------------------------------
Windows-win32:                YES  
                                              YES
Windows-gtk2:                   
NO                                                 YES
Windows-Qt:                     
YES                                                 YES
Linux-Gtk2:                        
NO                                                  NO
Linux-Qt:                            
YES                                                 NO


LCL as UTF16

OS-WidgetSet                   Conversion LCL <-> WidgetSet     
Conversion LCL <-> System calls
-----------------                ---------------------------------     
-----------------------------------
Windows-win32:                NO  
                                              NO
Windows-gtk2:                  YES 
                                               NO
Windows-Qt:                     NO 
                                                NO
Linux-Gtk2:                        YES 
                                               YES
Linux-Qt:                            NO 
                                                YES


LCL as RtlString

OS-WidgetSet                   Conversion LCL <-> WidgetSet     
Conversion LCL <-> System calls
-----------------                ---------------------------------     
-----------------------------------
Windows-win32:                NO  
                                              NO
Windows-gtk2:                  YES 
                                               NO
Windows-Qt:                     NO 
                                                NO
Linux-Gtk2:                       NO 
                                               NO
Linux-Qt:                           YES 
                                               NO

Luiz





More information about the fpc-devel mailing list