[Lazarus] Converting all code to use UnicodeString

Juha Manninen juha.manninen62 at gmail.com
Tue Sep 26 11:31:56 CEST 2017


On Tue, Sep 26, 2017 at 4:37 AM, Marcos Douglas B. Santos via Lazarus
<lazarus at lists.lazarus-ide.org> wrote:
> But according with this table, I shouldn't do that because so many
> problems could happen.
> http://wiki.freepascal.org/Unicode_Support_in_Lazarus#Without_.7B.24codepage_utf8.7D_or_compilerswitch_-FcUTF8

No. It works when assigning to String and that is what matters.


>> The solution is to NOT use Windows codepages.
>> ...
> So, no problems here and the page is outdated. OK.

The page is correct but your code and/or data is outdated if it uses
the Windows codepage encoding. :)
Well, honestly, why do you still use it?
Unicode has been around for decades. It solved all the horrible
problems inherent to locale dependent codepages. Windows has supported
full Unicode for ~18 years.
Maybe there still is a valid reason to use codepages but I don't know
what it is.


> Like I said, it's a hack. But, again, it was|is a great job. No doubt.

Yes. The wiki page lists 3 simple rules:
* Normally use type "String" instead of UTF8String or UnicodeString.
* Assign a constant always to a type String variable.
* Use type UnicodeString explicitly for API calls that need it.

For you I would add:
* Use Unicode instead of Windows system codepages.

With those rules the code is mostly compatible with Delphi. Not bad.

Juha


More information about the Lazarus mailing list