是否有像 iswctype()
这样的窄字符函数?对于宽字符?
更新
我没有意识到有 std::regex_traits::isctype()
,否则我会让问题更好地解释情况:
我实际上是在执行 std::ctype<char>
facet 本身所以我不能使用 std::regex_traits::isctype()
因为它本身取决于 std::ctype<char>::is()
.
请改用 POSIX 或 C99 函数。
最佳答案
POSIX says , 对于扩展字符类,
The charclass-name can be used as the property argument to the
wctype()
function, in regular expression and shell pattern-matching bracket expressions, and by thetr
command.
和the POSIX regex page ,相应地,说
In addition, character class expressions of the form:
[:name:]
are recognized in those locales where the name keyword has been given a charclass definition in the
LC_CTYPE
category.
因此,要在窄字符语言环境中实现扩展分类,唯一符合 POSIX 标准的方法似乎是 POSIX regex 类,就像在 C++ 中实现它的唯一方法是已经提到的 std::regex_traits::isctype
.
也许您最好了解特定于平台的 API,这些功能是根据这些 API 实现的(在可访问的地方)。
PS:也许更实用的方法是只调用btowc
和iswctype
。至少可以说,对窄字符及其加宽形式进行不同分类的语言环境是有问题的。
关于c++ - 是否有 iswctype() 函数的窄字符版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20982769/