[fpc-devel] TRegistry and Unicode

Michael Van Canneyt michael at freepascal.org
Mon Feb 25 21:27:12 CET 2019



On Mon, 25 Feb 2019, Bart wrote:

> Hi,
>
> I'm currently involved in some TRegistry bugs and regressions.
> Personally I don't use TRegistry in any of my programs.
> Also I mostly use Lazarus, so most most of the issues don't affect me.
>
> However I would like to share som observations and thoughts.
>
> TRegistry on Windows now (3.2+) uses Unicode API.
> String input parameters in the various methods get "promoted" to
> Unicode and then the API is called.
> Returned string values however are mostly encode in UTF8, by
> explicitely calling Utf8Encode(SomeUnicodeString).
> Is that (enforce UTF8 encoding) by design?
> (The Ansi to Unicode was done via UTF8Decode which is definitively
> wrong and is fixed by now.)
>
> On Lazarus, this no problem, since by default all strings are UTF8
> encoded, so all conversions are lossless.

I think Lazarus users are the main TRegistry users, so I would keep current
behaviour for the public API. Where possible add overloads that use a
unicodestring, and let the UTF8 one call the unicode one.

Under the hood, you can then completely switch to UnicodeString if that makes 
it easier.

The XML registry also works with Unicode string, since DOM uses unicodestring.

Michael.



More information about the fpc-devel mailing list