DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2822
Version: 1.3-current


Using Fl_Input::insert() with real UTF-8 strings, I found the
documentation and/or the functionality of the positional parameters
not clear/sufficient for my purpose.

Citing my email to fltk.general from 2012/04/12:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I have a question in regarding use of the Fl_Input::insert() method
in combination with UTF-8 strings.

If I want to insert a text after the second UTF-8 character, it
would seem natural to use:

---- snip ----
#include <FL/Fl_Input.H>
#include <stdio.h>
int main()
{
  Fl_Input t(0,0,0,0);
  t.value( "ДБИЯ" );
  t.position( 2 );
  printf( "t.value(): '%s' size=%d\n", t.value(), t.size());
  t.insert( "Ж" );
  printf( "t.value(): '%s' size=%d\n", t.value(), t.size());
  printf( "t.position(): %d\n", t.position());
}
---- snip ----

But it looks like position(2) sets the position to the byte-offset 2
and not after the second *UTF-8 character*, as the outcome is:

---- snip ----
t.value(): 'ДБИЯ' size=8
t.position(): 2
t.value(): 'ДЖБИЯ' size=10
t.position(): 4
---- snip ----

How is it supposed to be done and is this the desired behaviour?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


I don't know if a change in behaviour, so that position means
'UTF-8 character position' and NOT 'byte offset', will not break
the API, so this might be an issue for 1.4 or 3.0.

Also I imagine, that other methods of Fl_Input could suffer
the same issues (size(),...)


Link: http://www.fltk.org/str.php?L2822
Version: 1.3-current

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

Reply via email to