gpt4 book ai didi

c++ - 是否有 iswctype() 函数的窄字符版本?

转载 作者:太空狗 更新时间:2023-10-29 23:04:56 25 4
gpt4 key购买 nike

是否有像 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 the tr 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:也许更实用的方法是只调用btowciswctype。至少可以说,对窄字符及其加宽形式进行不同分类的语言环境是有问题的。

关于c++ - 是否有 iswctype() 函数的窄字符版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20982769/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com