On 15/09/2011 10:16, Michael Schnell wrote: > In fact users want to deal with "decently coded characters" and not > with "cryptic bytes some of which together are representing a > character". (e.g. when doing MyChar := MyString[1]; )
None of our company's users using our products would even know what the hell you are talking about. :-) But to convert your example to UTF-8 as would be done in a fpGUI application (which I again is never really require in real world applications), it would look as follows: var MyChar: TfpgChar; MyString: TfpgString; begin MyString := 'some unicode string even with chars outside BMP'; MyChar := UTF8Copy(MyString, 1, 1); The above example is safe, and will always give the correct result, even for Unicode characters above the BMP. And I don't need to worry about endianness (byte order) - unlike UTF-16 which could be in UTF-16BE or UTF-16LE and a Unicode "character" could be a surrogate pair - so your example would fail there too. Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel