[fpc-devel] TRegistry and Unicode

Bart bartjunk64 at gmail.com
Tue Feb 26 19:12:26 CET 2019

On Tue, Feb 26, 2019 at 11:04 AM Michael Van Canneyt
<michael at freepascal.org> wrote:

> If I understood the OP correct, he wants to change the use of "string"
> arguments in the public API to unicodestring.
> That changes a lot.

And that's why I asked here first.

> (See e.g. https://bugs.freepascal.org/view.php?id=35113
> for a similar situation where part of the error is that the lazarus
> user must explicitly call Utf8Decode.)

In Lazarus (with UTF8hack) assigning a UnicodeString to an AnsiString
will call Utf16ToUtf8 on the implicit conversion.
So, explicitely calling Utf8Encode should not be necessary.

> So my proposal is to leave the public API as-is, using string, adding

This leaves my initial "itch": input strings are CP_ACP (so can be
anything), output strings are CP_UTF8 always.
Why do we convert:
SomeUnicodeString := SomeAnsiString (implicit conversion using
SomeAnsiString := Utf8Encode(SomeUniCodeString) (explicit conversion
bypassing WideStringManager)

IMHO this is rather inconsistent and it makes no sense from the
viewpoint of "pure" freepascal users.
(Again: Lazarus users don't care one way or the other.)

E.g. compare that to FindFirst with AnsiString: it implicitely
converts Ansi- to UnicodeString and lets the WidestringManager handle
the conversion back to AnsiString.

> unicode string overloads where possible/useful.

That would mean overloading almost all methods.


More information about the fpc-devel mailing list