我应该使用什么来代替 g_strncasecmp?
看起来 g_strncasecmp 已被弃用,所以我正在寻找另一个函数来做同样的事情。
It looks like g_strncasecmp is deprecated, so I am looking for another function to do the same thing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
来自文档
http://library.gnome。 org/devel/glib/stable/glib-String-Utility-Functions.html#g-strncasecmp
“因此有两个替换函数:g_ascii_strncasecmp(),它仅适用于 ASCII 并且不区分区域设置,并且g_utf8_casefold(),这对于 UTF-8 的不区分大小写排序很有用。”
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
表示纯 ASCII,g_utf8_casefold
如果您有 UTF-8 字符串。g_ascii_strncasecmp
for pure ASCII andg_utf8_casefold
if you have UTF-8 strings.如果您要比较许多相同的字符串,则可以通过创建排序规则键来提高速度。使用
执行此操作g_utf8_collate_key()
,然后您可以使用g_ascii_strcmp()
因为排序规则键是 ASCII 字符串。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 usingg_ascii_strcmp()
since the collation key is an ASCII string.