Me:
> What we can do, and this is what you won't like, is assume that the
> index into the byte array always points to a valid ascii character
> in the range 0x01-0x7f, or a cp1252 mapping character 0x80-0x9f if
> the appropriate #defines are set, or first byte of a utf-8 sequence.
> [this may be a huge code invariant to get right and debug fully!]
> We then use fl_utf8decode() and fl_utf8encode() pairs for all bytes
> with the top bit set. This would give the 0x80-0x9f mappings to the
> equivalent Unicode characters, and expand it to the utf-8 sequence.
>
> Does this sound like I might be on the right track?
>
> For other widgets, i.e. not Fl_Test_{Buffer,Display,Editor}, do we
> need to redefine fl_utf8len() so that it returns 1 for utf-8 trailing
> bytes, so that we can cope with the cp1252 0x80-0x9f characters?
> I suspect that this would also be a major rewrite...

Just to add something that struck me while waiting to fall asleep
last night...

As well as being able to count forward by the correct number of bytes,
in order to move the cursor right by one character for example, we also
need to be able to count backward by the correct number of bytes, eg to
move the cursor left. And counting backwards now seems to be a more
complicated action, because now we need to know the preceding bytes too.

Consider the sequence  aaa12a123aa1234aXXaa  made up at random, where
"a" is a plain ascii byte (0x01-0x7f), "1" is a utf-8 header byte and
"2", "3" and "4" are utf-8 trailing bytes, and "X" is a cp1252 mapped
byte (0x80-0x9f). Unfortunately some of the 234 bytes will also be in
the 0x80-0x9f range, so to determine whether we have an X byte or a
234 byte, we must check the previous byte to see whether this is an
ascii byte, or a utf-8 header byte, and if not, check the byte before
that etc. FLTK is limited to 4-byte utf-8 sequences, so we might need
to consider the 4 [or 5?] previous characters, just to make sure we
don't have a line of 0x80 euro characters...

In the non- Fl_Text_{Buffer,Display,Editor} widgets, will users need
to program all of this logic for themselves if they need cut'n'paste
between input field widgets?

Cheers
D.
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to