Re: G_UTF8String: Boxed Type Proposal





On 03/18/2016 10:33 AM, Nicolas George wrote:
[ Replying a little randomly to this message. ]

Randall Sawyer:
3) Wouldn't it be helpful to keep track of how many code points
("characters")are stored in the GString - a number which may be less than
the value of GString.len - without needing to call g_utf8_strlen() each time
to find out?
IMnsHO, NO, definitely not.

To the people who want this feature: why do you want it? The octet length is
necessary to copy the string, store it in a file, send it to network.

But what use is the number of Unicode code points? Or their index in the
string? 

In my experience, the almost-only relevant treatment to an Unicode string is
to walk over, character by character, applying parsing or typographic
algorithms. Knowing how many code points, or even graphemes, were in a given
span or the whole string is almost always irrelevant.

Regards,



Three answers:

1) Interface Developer Support

2) Relevant reusable code

3) Completeness

bash-4.3$ pwd
/usr/src/gtk+-3.18.5_1/gtk
bash-4.3$ grep -l g_utf8_offset_to_pointer *.c

gtkentry.c
gtkentrybuffer.c
gtklabel.c
gtkpango.c
gtktextbtree.c
gtktextbuffer.c
gtktextiter.c
gtktextlayout.c
bash-4.3$ grep -l g_utf8_pointer_to_offset *.c
gtkentry.c
gtkfilechooserentry.c
gtklabel.c
gtkpango.c
gtkprintoperation.c

Looking through the function definitions in the source files listed above, I see the same procedures being performed repeatedly and the same sorts of parallel storage of byte length and code point ("character" - in Gtk parlance) length in string storage structures.

Wouldn't it make for cleaner code and for more flexible extensibility for developers if the glib API were to provide these in the background to begin with?

Thanks to all.

PS: /usr/src is where I put untarred distributed source for some of the packages I have installed.

_______________________________________________
gtk-devel-list mailing list
gtk-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]