Re: Deprecated functions



"Richard Warren" <rew primagraphics co uk> writes:
> 
> Various functions are marked as deprecated in the Glib Reference Manual (and
> GTK etc.) with comments such as "This function is deprecated and should not
> be used in newly-written code" but no further explanation.
> 
> Would it be possible in the future to add a brief reason why and/or a
> suggestion of what should be used instead please?

The warnings are autogenerated, that's why they don't explain much. 
It would be good to have more explanation in the docs for the
function, I agree. Just not enough time in the day...

> In this particular instance, I'm thinking of g_strncasecmp() in V1.3.9.

The problem with g_strncasecmp() is that it does the comparison by
calling toupper()/tolower() on each byte. toupper()/tolower() are
locale-specific. However, it is impossible to handle things correctly
from an i18n standpoint by operating on bytes, since characters may be
multibyte. Thus g_strncasecmp() is broken if your string is guaranteed
to be ASCII, since it's locale-sensitive, and it's broken if your
string is localized, since it doesn't work on many encodings at all,
including UTF-8, EUC-JP, etc.

There are therefore two replacement functions:
 g_ascii_strncasecmp(): only works on ASCII, not locale-sensitive
 g_utf8_casefold(): good for case-insensitive sorting of UTF-8

I just put the above explanation in the docs, so should help people in
the future.

Havoc






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