Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2008-07

UTF-16 versions of Length, Pos, Delete etc.

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

Has anybody already implemented the string utility functions like Length, Pos, Delete, Copy, Insert etc. that works with UTF-16. I'm not interested in UCS2 only support, I want full UTF-16 support.

I'm willing to implement those, but why reinvent the wheel when somebody already did it before... :)

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Martin Schreiber
to Graeme Geldenhuys
Graeme Geldenhuys wrote 9 lines
Hi, Has anybody already implemented the string utility functions like Length, Pos, Delete, Copy, Insert etc. that works with UTF-16. I'm not interested in UCS2 only support, I want full UTF-16 support. I'm willing to implement those, but why reinvent the wheel when somebody already did it before... :)

Use the normal FPC widestring routines. There is no difference between handling of UCS2 or utf-16 except that ucs2string[<n>] always returns a codepoint. Pos() works for UCS2 and utf-16.
If you must work with character cells of the whole Unicode range which are addressed by an index, you should convert to an array of ucs4char before processing.
Please note that a glyph often is composed by more than one codepoint.

Martin