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
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to