[fpc-devel] TRegistry and Unicode
jura at cp-lab.com
Wed Mar 6 22:08:51 CET 2019
On 06.03.2019 22:21, Bart wrote:
> Using UTF8String in TRegistry instead of String forces users to
> consider the fact that returned strings are Utf8Encoded now always,
> even if they (probably most of them) do not need that because what
> they retrieve from and put in the registry fits into their codepage.
> And somebody out there will have code that checks if
> ReturnedString[Index] = #$E4 ("ä" in my codepage), and have the
> sourcefile in ANSI (system codepage), and now this will fail, because
> that character will now be made up of 2 bytes.
If you declare a function result as utf8string instead of string (ansistring) then automatic conversion will be
performed when you assign the result of the function to a variable of type string (ansistring). You will gen a classic
1-byte per character string if your current encoding is 1-byte encoding.
I mentioned this earlier.
Just check this. Change the declaration to:
function TRegistry.ReadString(const Name: utf8string): utf8string;
More information about the fpc-devel