[Lazarus] Does Lazarus support a complete Unicode Component Library?

Graeme Geldenhuys graemeg.lists at gmail.com
Wed Feb 16 08:30:23 CET 2011


Op 2011-02-16 09:12, Jürgen Hestermann het geskryf:
> 
> That's sounds like yet another approach. So up to now I see 3 models how
> strings could be handled:

UnicodeString should become the default. I would even go as far as
recommending that String = UnicodeString in a newer FPC version.

UTF8String is not a special type, it is simply a UnicodeString that has
it's encoding bit set to UTF-8. UTF8String is still a UnicodeString as
far as the compiler is concerned. It's an "alias type".

Just like we now use String everywhere, in future we could use
UnicodeString everywhere and don't need to worry about what encoding we
are using. This should even be the case when we talk to OS API's or
external libraries. By default libraries under Windows use UTF-16. Your
UnicodeString under Windows will already be in UTF-16 - thus no
conversion needed. Same for Linux. By default most libraries use UTF-8,
and UnicodeString will automatically be in UTF-8 encoding anyway - thus
again no conversion needed.

All RTL functions which use UnicodeString will obviously be the correct
encoding on each platform too. So again by default, simply using
UnicodeString will not require any encoding conversions.

Will will work for 99% all all applications. Only when the developer
wants to do something specific with a specific encoding, that developer
can simply define a new string type as follows:
eg:
   type
     MyCP850StringType = UnicodeString(cp850);

That developer can then use that string knowing the encoding is CP850.
But this would be very seldom needed.

As for the LCL or any libraries. They could simply use UnicodeString
everywhere (thus my recommendation that String = UnicodeString in the
future so our code wouldn't need much changing), and it will work just
fine under all platforms, because UnicodeString will default to each
platforms default encoding.



Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/





More information about the Lazarus mailing list