[Lazarus] UTF8String and UTF8Delete

Sven Barth pascaldragon at googlemail.com
Sun Dec 13 21:32:08 CET 2015


On 13.12.2015 11:37, Jürgen Hestermann wrote:
>  > And hence, at that point in time, there would (for programmers using
>  > Lazarus) bee no need to use the type Utf8String at all.
>
> Then I would suggest to remove this type.
>
>

Utf8String is part of the FPC RTL and is just a shorthand for 
AnsiString(CP_UTF8). That the LCL provides String routines that don't 
take an Utf8String, but an AnsiString, aka AnsiString(CP_ACP) is not the 
fault of the Utf8String type, so it will stay. Period.

> But I still don't understand the rationale behind the decision to not allow
> ansistring(A) to be fed into a var parameter of ansistring(B).
> I would expect that *all* ansistrings are assignement compatible.

They *are* assignment compatible, just like ShortString and 
UnicodeString are assignment compatible. But they are different types 
and just like you can't pass a UnicodeString to a function expecting a 
ShortString var parameter you can't pass an AnsiString(CP_UTF8) to a 
function expecting a AnsiString(CP_ACP). Simply consider them as 
different types with automatic type conversions between them...

Regards,
Sven




More information about the Lazarus mailing list