且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

提升string_algo的to_upper函数不考虑语言环境

更新时间:2023-11-26 15:15:04

std :: toupper假定为​​1:1转换,因此从ß到SS的情况(没有Boost.StringAlgo)都没有希望.

std::toupper assumes a 1:1 conversion, so there is no hope for the ß to SS case, Boost.StringAlgo or not.

查看 StringAlgo的代码,我们看到它确实使用语言环境(似乎Borland除外).因此,对于另一种情况,我很好奇:您的平台上toupper('ó', std::locale("es_CO.UTF-8"))的结果是什么?

Looking at StringAlgo's code, we see that it does use the locale (Except on Borland, it seems). So, for the other case, I'm curious: What is the result of toupper('ó', std::locale("es_CO.UTF-8"))on your platform?

以上内容使我想到了其他事情:源代码中字符串的编码是什么? UTF8?在这种情况下,std :: toupper将看到两个代码单元ó",因此没有希望.拉丁文1?在这种情况下,使用名为".UTF-8"的语言环境是不一致的.

Writing the above makes me think about something else: What is the encoding of the strings in your sources? UTF8? In that case, std::toupper will see two code units for 'ó', so there is no hope. Latin1? In that case, using a locale named ".UTF-8" is inconsistent.