[Lazarus] Feature Request: Insert {codepage UTF8} per default

Michael W. Vogel m-w-vogel at gmx.de
Wed Mar 30 11:38:21 CEST 2016

Am 30.03.2016 um 10:11 schrieb Mattias Gaertner:
> You have to distinguish between with CP_UTF8 as default and with 
> CP_ACP as default. 
Yes, I know it. What I mean with default:

Go to Project -> New Project ... -> Application

Now a new Application is created. With the added patch {$codepage UTF8} 
is added and thats right, cause if you save the file to anywhere it is 
UTF-8 encoded. There is nothing wrong.

Am 30.03.2016 um 10:11 schrieb Mattias Gaertner:
> Both have cases where some string combinations fail. 
With the hack that the LCL makes and the added {$codepage UTF8} all 
conversions work like a charm (see added testproject).

If you want to use -dDisableUTF8RTL, you have to know, what you do.
- remove {$codepage UTF8}, better set it to the valid codepage or use 
- save all the source files with the wanted encoding/codepage

So IMHO this special case wouldn't be used much. All the puzzled 
discussions I can see in the forums are about the default applications 
created with Lazarus (not FPC), that uses the LCL.

Am 30.03.2016 um 10:11 schrieb Mattias Gaertner:
> LCL applications nowadays use CP_UTF8 as default. We (laz team) tested 
> adding -FcUTF8 and it failed in too many cases. Also it adds some 
> overhead. So we decided to *not* add it by default. 
I also don't want it. I want a added {$codepage UTF8}, if the file is 
saved as a UTF-8 encoded one.

Am 30.03.2016 um 10:11 schrieb Mattias Gaertner:
>>   Offtopic: In the added project: Why is a const 'abc' with {$codepage UTF8} a
>> Unicodestring (Windows7, 64bit, Lazarus 1.7 r52077M FPC 3.1.1
>> i386-win32-win32/win64 on FPC 3.1.1 r33371)?
> There is no compile-time flag to tell the compiler what codepage the system is
> using at runtime. So it assumes current Windows codepage. Any string literal not
> in this codepage is stored as UTF-16.
Thanks for that hint!

More information about the Lazarus mailing list