[Lazarus] substr return wrong string with some utf8 char

Hans-Peter Diettrich DrDiettrich1 at aol.com
Thu Feb 10 15:20:51 CET 2011


claude Pomalo schrieb:

> i use the substr function to get some truncated string.
> these string are in french language  and sometimes contains "à" or "é" 
> etc.. char
> When these charaters are in the string the wrong substr is return
> substr (pierre à feu,11) return 'pierre à  f' not 'pierre à fr'
> 
> length('à') return 2
> utf8length('à') return 1

It looks to me as if Length returns the byte count, while Utf8Length 
returns the character count.

> is a utf8Subst() like function exist?

I'd use Pos to get the byte index of the part to copy or remove.

DoDi





More information about the Lazarus mailing list