[fpc-devel] for-in-index loop

Michael Schnell mschnell at lumino.de
Fri Jan 25 11:51:23 CET 2013


On 01/25/2013 11:39 AM, Daniƫl Mantione wrote:
>
> Yes, it is a known fact that this is a weakness of UTF-8. 
Maybe you should say its a  feature.
> Consider transforming the string to UTF-16, UTF-32 or even an internal 
> datastructure before doing the random access.
This has been already discussed here at any length, resulting in the 
knowledge that this also does not help in all cases (as all Unicode 
variants allow for extended codes).

Delphi XE and mse use UTF-16 by default as a (in most cases appropriate) 
compromise. I suppose, FPC and Lazarus will follow at some point in 
time, making  these discussions less stringent.

A decent smart "indexer" class with appropriate enumerator/iterator-like 
compiler-magic syntax might help until then and is a lot nicer than the 
old-fashioned myString[i] notation anyway, on top of being compatible 
with any future string implementations.

-Michael



More information about the fpc-devel mailing list