[fpc-devel] assign constant text to widestring

Florian Klaempfl florian at freepascal.org
Thu Oct 23 13:31:30 CEST 2008


Michael Schnell schrieb:
> 
>> The conversion
>> utf-8<->utf-16 is a very expensive operation and the compiler has to
>> insert it all over the place and people would cry about the performance
>> of their programs.
> Of course I do agree.
> 
> If you want to care about performance you need to know what to do:
> Either use WideString "all over the place" and beware of the LCL API, or
> use UTF8String  all over the place.
> 
> But if you use UTF8String you need to be aware that you can't do simple
> and totally normal things like s := copy(s, 3); to get the first three
> characters of a string. Really finding the first three characters of a
> string is an interesting and time consuming task with utf8 ;) .

This is also a simplified view.
- firstly, which real world (!) task really requires to execute an
operation like this, mostly it's something like copy(s,pos(...),...);
- secondly, a properly coded utf-16 application shouldn't do this
either: it doesn't handle surrogates properly and e.g. umlauts can be
encoded in all utf flavours as two "chars": base letter plus the umlaut
(the two dots).



More information about the fpc-devel mailing list