[fpc-devel] Unnecessary string copy from Utf8String to AnsiString if destination CP is UTF8

Ondrej Pokorny lazarus at kluug.net
Sun Apr 28 14:14:37 CEST 2019


On 28.04.2019 13:45, J. Gareth Moreton wrote:
> Personally I'm fine with people refactoring code in order to improve 
> performance in either the compiler or the programs it compiles, just 
> so long as it behaves exactly the same as before (which in this case, 
> it doesn't because of the empty string issue that Jonas mentioned).

What empty string issue? Did I miss something?

program AnsiUtf8;
var
   Utf8Str: UTF8String;
   Str: AnsiString;
begin
   DefaultSystemCodePage := 1250;
   Utf8Str := 'hello';
   Str := Utf8Str;
   Writeln(Str);
end.

Ondrej




More information about the fpc-devel mailing list