[Lazarus] UTF8String and UTF8Delete

Mattias Gaertner nc-gaertnma at netcologne.de
Fri Dec 11 13:06:49 CET 2015


On Fri, 11 Dec 2015 09:10:42 +0100
"Jürgen Hestermann" <Juergen.Hestermann at gmx.de> wrote:

> UTF8Delete probably takes an AnsiString (or String) as var parameter and for var parameters the static codepages have to match exactly (String has CP_ACP while Utf8String has CP_UTF8).
>  
> Just please help me understanding this:
> The unit LazUTF8 unit is for manipulating UTF8 strings only, correct?

Yes.

> Is there any reason that all functions are declared with
> parameter type STRING instead of UTF8String?

Yes, because the FCL uses String.
See below.

> For what else should I use UTF8delete if not for UTF8strings?

For "UTF8 strings".
An "UTF8String" and an "UTF8 String" are two different things for the
compiler. See below.


> And what happens if the string has a different encoding than UTF8?
> I doubt that the function will produce any useful result in this case
> because it expects UTF8.

Yes, invalid for chars above #127.

See here:
http://wiki.lazarus.freepascal.org/Better_Unicode_Support_in_Lazarus#Why_not_use_UTF8String_in_Lazarus.3F

Mattias




More information about the Lazarus mailing list