[Lazarus] cwstring in arm-linux

Graeme Geldenhuys graemeg.lists at gmail.com
Fri Oct 21 10:21:55 CEST 2011


On 2011-10-21 10:19, Hans-Peter Diettrich wrote:
> 
> Please specify "Finding", a code snippet would be nice.

Knock yourself out...


https://github.com/graemeg/fpGUI/blob/master/src/corelib/fpg_stringutils.pas


Take a look at UTF8Copy() or UTF8Insert() etc.


> in FPC, until now. Give an example of UTF-8 code, which would become 
> *more* complicated with UTF-16.

Consider a Copy() type function where you want to copy a Unicode
codepoint (think single character as you see on the screen - ignoring
combining diacritics for now) out from a string. UTF8Copy() as defined
above will do that correctly, irrespective if the codepoint is in the
BMP or Supplementary Plane or if the character is represented by 1,2,3
or 4 bytes in length.

With UTF-16 you need to check if the UTF-16 string is Little Indian or
Big Indian (UTF-16BE or UTF-16LE), whether the codepoint has a surrogate
pair or not. All in all, a lot more complex than UTF-8.


Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/





More information about the Lazarus mailing list