Zitat von Graeme Geldenhuys <[EMAIL PROTECTED]>:

> On 08/10/2007, Razvan Adrian Bogdan <[EMAIL PROTECTED]> wrote:
> > char would be nice too, maybe even implemented in FPC for UTF8string
> > such as Lenght(utf8string) or indexing utf8string[1] to return the
> > char not the byte as UTF32.
>
> In fpGUI I have a few helper functions for UTF-8 strings (Length,
> Copy, Delete, Insert, Pos etc). Some of the code I got from LCLProc
> unit and some written myself.
>
> Anybody know how I can access UTF-8 characters via a index?   eg;
> MyString[2] returns the string containing the 2nd character. I say
> returning a string, because a UTF-8 characters can be between 1-4
> bytes so a Char type will not do.

If you want an array, then you can convert the string to UTF-32 or create an
array of PChar pointing to each character.
If you just want the n-th utf-8 character, then you can use UTF8CharStart.
If you need the n-th visible character (including BIDI and combined characters)
then you must use functions from the iconv lib or the winapi. Same for UTF-16
and UTF-32.
There is no encoding for random access to an unicode string.


Mattias

_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to