But how can i change 1 character in an UTF8 string ?
old : s[2]:='A';
First, be careful with the term "
character". It can mean many things in Unicode. One meaning is still the "
codeunit" which here is Pascal "
Char" type.
One meaning is a "
user perceived character" which is different from a "
codepoint".
Anyway, "characters" or codepoints must be treated as strings when replacing them because their lengths may differ.
StringReplace works because it supports different lengths for its input strings.
Unit LazUTF8 also has UTF8StringReplace which takes care of upper-/lowercase rules of Unicode.
Otherwise you must do some Copy() calls to construct a new string from the start, middle and end parts.
These examples may give you ideas:
http://wiki.freepascal.org/UTF8_strings_and_charactersRemember, you can also do encoding agnostic code with unit LazUnicode.