Re: G_UTF8String: Boxed Type Proposal

On Wed, Mar 16, 2016 at 6:58 PM, Randall Sawyer
<srandallsawyer hushmail me> wrote:
I have a question at the end of this! Please answer if you think it will

Hi Randall,

thanks for contributing!

I propose the development of a new boxed type for the Glib API named
"G_UTF8String". I have searched through this mailing list's archives to see
if anyone else has proposed anything similar. I have not found any.

I believe that you haven't found such a proposal because most people
don't see much use in a separate boxed type for utf8 strings. Every
string we pass around in GLib and GTK+, and every char * in their APIs
is expected to be in utf8. The few exceptions to this rule are
explicitly documented.

The main reason you mention for wanting such a type is to do away with
the need for repeatedly calculating the character count. I think this
falls into the same category as the length of the string in bytes - C
doesn't have counted strings either, and expects you to just call
strlen() over and over again. In practice, most strings we're handling
are short enough for this to not be much of an issue.

GLib already provides a number of utilities for dealing with utf8
strings in terms of characters, such as g_utf8_strlen,
g_utf8_substring, g_utf8_find_next/prev_char. We can certainly discuss
adding to that list, if there are glaring omissions.

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