为什么有多个 C 函数进行不区分大小写的比较 [英] Why are there multiple C functions for case-insensitive comparison

查看:59
本文介绍了为什么有多个 C 函数进行不区分大小写的比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了在不考虑大小写的情况下比较任何字符串,有各种 C 库函数,例如 strcasecmp()stricmp()strcmpi()代码>.这些有什么区别?

For comparing any strings without considering their case, there are various C library functions such as strcasecmp(), stricmp() and stricmpi(). What is the difference between these?

推荐答案

有多种方法可以做很多事情,主要是因为标准过程滞后于实现.人们看到需要一个函数(在这种情况下,不区分大小写的字符串比较),一些编译器编写者/库编写者实现了一个名为 strcmpi 的函数,而另一组实现了 stricmp,另一组认为没有必要实施,另一组实施strcasecmp,另一组实施strcmpnocase,等等.战斗和获胜者的实现成为语言的一部分.同时,其他实现继续使用其他命名方法,并且语言变得更强大/碎片/增益膨胀(取决于您的观点).

There are multiple ways to do many things primarily because the standards process lags behind implementations. People see the need for a function (in this case, case insensitive string comparison) and some compiler writers/library writers implement a function called strcmpi, while another group implements stricmp, while another group decides it is not necessary to implement it, while another group implements strcasecmp while another group implements strcmpnocase, etc. Years later, representatives from the various groups meet in mortal combat and the winner's implementation becomes part of the language. Meanwhile, the other implementations continue with the other-named methods and the language grows stronger/fragments/gains bloat (depending on your point of view).

这篇关于为什么有多个 C 函数进行不区分大小写的比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆