C 中土耳其语I的解决方案
Solution for Turkish-I in C++
嗨,hi all!
在土耳其语中,字母之一的字母具有不同的行为,就是i和i-。在英语中,我和我很高&较低的情况。在土耳其小写中,我不是我,而是ı。
因此,在土耳其环境(即窗口)中," domain.com"answers" domain.com"并不相等。由于电子邮件运输&DNS完全用英语,如果邮件地址包含大写I,则可能有问题。
在c#中,我们可以使用 novariantcultureignorecase flag纠正问题:
// Mock
string localDomain = "domain.com";
string mailAddress = "USER@DOMAIN.COM";
string domainOfAddress = mailAddress.Split('@')[1];
string localInbox = "";
//
// Local inbox check
//Case insensitive method
bool ignoreCase = true; // Equal to StringComparison.CurrentCultureIgnoreCase
if (System.String.Compare(localDomain, domainOfAddress, ignoreCase) == 0)
{
// This one fails in Turkish environment
localInbox = mailAddress.Split('@')[0];
}
//Culture-safe version
if (System.String.Compare(localDomain, domainOfAddress, StringComparison.InvariantCultureIgnoreCase) == 0)
{
// This one is the correct/universal method
localInbox = mailAddress.Split('@')[0];
}
由于我在C 上没有经验,这两个示例的 c 等效是什么?
如果您在Windows
中编程,则可以将线程的locale
更改为en_US
,然后使用_stricmp
,或为en_US
创建一个局部对象,然后使用_stricmp_l
:
setlocale( LC_CTYPE, "English" );
assert( _stricmp("DOMAIN", "domain") == 0 );
_locale_t l = _create_locale( LC_CTYPE, "English" );
assert( _stricmp_l("DOMAIN", "domain", l) == 0 );
如果boost
是您的选项,那么一种更便携的和C 友好的解决方案是使用Boost :: Locale Library
相关文章:
- 运行同一解决方案的另一个项目的项目
- Project Euler问题4的错误解决方案
- 计算每个节点的树高,帮助我解释这个代码解决方案
- C++:Application.cpp中抛出了未解析的外部符号(解决方案在问题的末尾,供未来的读者参考)
- visual c++,如何获取解决方案目录中的代码
- 有没有办法在远程设备上打开和编辑visual Studio 2017解决方案
- C++Matching Brackets 2解决方案不起作用
- 在 ubuntu3 上C++ goto 定义有什么解决方案吗16.04?
- 在 leetcode 上提交解决方案时出现堆栈缓冲区溢出错误
- 我的固定时间步长与增量时间和插值的解决方案是错误的吗?
- 无法在问题解决方案中执行输出逻辑
- 最大的回文产品 - 程序未运行,编写解决方案但无法理解问题
- 从预序遍历构造 bst 的 c++ 和 python 解决方案之间的区别
- 在一个解决方案中针对第三方静态库 (Creo) 的不同版本(版本)进行构建
- 如何巧妙地编写两个函数——一个用于检查是否存在解决方案,另一个用于获取所有解决方案
- 使用 Git 处理 C++ Visual Studio 2019 解决方案的外部依赖项源代码管理的最佳方法是什么?
- N-queen问题:无法弄清楚为什么我的解决方案不起作用
- 从排序数组中删除重复项,具有不同代码方式的相同解决方案具有不同的输出
- C 中土耳其语I的解决方案
- 在c++中绘制(原语,线条等)的最佳通用跨平台解决方案