On Thu, Oct 20, 2011 at 4:19 PM, Michael Schnell <[email protected]> wrote: > I was not at all happy trying to convert them to the "always UTF-8" version > of Lazarus.
Well, here is the surprise now: utf-8 was chosen exactly to facilitate porting old applications while still supporting all of the Unicode standard. Length does not give the number of chars? No problem: uses lazutf8; function UTF8Length(const s: string): PtrInt; How to iterate through chars? Using this: function UTF8CharacterLength(p: PChar): integer; How to find the n-th char? // find the n-th UTF8 character, ignoring BIDI function UTF8CharStart(UTF8Str: PChar; Len, CharIndex: PtrInt): PChar; // find the byte index of the n-th UTF8 character, ignoring BIDI (byte len of substr) function UTF8CharToByteIndex(UTF8Str: PChar; Len, CharIndex: PtrInt): PtrInt; Having problems in Pos, Copy, Delete or Insert? Just replace with these: function UTF8Pos(const SearchForText, SearchInText: string): PtrInt; function UTF8Copy(const s: string; StartCharIndex, CharCount: PtrInt): string; procedure UTF8Delete(var s: String; StartCharIndex, CharCount: PtrInt); procedure UTF8Insert(const source: String; var s: string; StartCharIndex: PtrInt); The switch is really easy. There are routines which are equivalent to all operations done previously. -- Felipe Monteiro de Carvalho -- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
