【发布时间】:2014-12-29 02:43:58
【问题描述】:
环境:boost1.53.0 c++11;
C++ 新手。
在 boost locale 边界分析中,为 word(eg.boundary::word_letter,boundary::word_number) 和 sentence 指定了规则类型,但没有为字符指定边界规则类型。我想要的只是isUpperCase(), isLowerCase(), isDigit(), isPunctuation()。
尝试了提升字符串算法,但不起作用。
boost::locale::generator gen;
std::locale loc = gen("ru_RU.UTF-8");
std::string context = "ДВ";
std::cout << boost::algorithm::all(context, boost::algorithm::is_upper(loc));
为什么这些特性可以在 Java 或 python 中轻松访问,但在 C++ 中却如此令人困惑?有什么方法可以实现这些吗?
【问题讨论】:
-
“boost string algorithm which didn't work”是什么意思,你的程序崩溃了?
-
= =!它没有按预期工作。结果错误。它只能处理 ascii 字母。再次感谢~
-
哪个操作系统?您的源文件保存在哪个代码页中?
-
unbuntu 12.04。一切都用 utf8 编码。
-
看看问题中的程序,stackoverflow.com/questions/27614666/…。与您正在尝试的非常相似,并且效果很好。只需根据您的程序更改它,当然更改语言环境,看看它是否有效