What should I use instread of g_strncasecmp?
It looks like g_strncasecmp is开发者_StackOverflow中文版 deprecated, so I am looking for another function to do the same thing.
From the docs at http://library.gnome.org/devel/glib/stable/glib-String-Utility-Functions.html#g-strncasecmp
"There are therefore two replacement functions: g_ascii_strncasecmp(), which only works on ASCII and is not locale-sensitive, and g_utf8_casefold(), which is good for case-insensitive sorting of UTF-8."
g_ascii_strncasecmp
for pure ASCII and g_utf8_casefold
if you have UTF-8 strings.
If you're going to be comparing a lot of the same strings, you can gain some speed by creating collation keys. Do this using g_utf8_collate_key()
, you can then compare the keys case-insensitively using g_ascii_strcmp()
since the collation key is an ASCII string.
精彩评论