[Lazarus] Problem with non-ascii chars fpc-3.0.0 vs fpc-3.1.1 under Windows
Bart
bartjunk64 at gmail.com
Thu Apr 28 14:26:04 CEST 2016
On 4/28/16, zeljko <zeljko at holobit.net> wrote:
> This is not true under windows 10 + fpc-3.0.0 when user name is Željko.
> CurrentDir & CurrentDirUTF8 returns C:\Users\Željko\test
> GetAppConfigDirUTF8(False) returns C:\Users\Željko\test
>
> GetEnvironmentVariable &
> GetEnvironmentVariableUTF8
> returns C:\Users\L"eljko <----- looks like wrong.
On Win7 (Lazarus trunk, fpc 3.0 32-bit) at least for unicode
characters inside my codepage GetEnvironmentVariableUTF8 retruns
correct string, encoded as UTF8, however StringCodePage is CP_ACP.
Not sure it this matters at all for your usecase, but GetAppConfigDir
returns a variable in UTF8 encoding where StringCodePage is CP_UTF8.
Example with
set zeljko=äëï
Result of StringCodePage in sqaure brackets:
GetEnvironmentVariableUtf8: zeljko = $C3 $A4 $C3 $AB $C3 $AF [0]
GetEnvironmentVariable with UnicodeString: zeljko = $00E4 $00EB $00EF [1200]
UTF16ToUTF8 on result of previous line: zeljko = $C3 $A4 $C3 $AB $C3 $AF [65001]
GetAppConfigDirUtf8: .... [65001]
As a workaround you may try to use the Unicode variant of
GetEnvironmentVariable and convert it to Utf8 with UTF16ToUtf8().
The resulting string (on my system) then has stringCodePage = CP_UTF8 again.
Bart
More information about the Lazarus
mailing list