在一个项目中,所有内部字符串都保存在 utf-8 编码中。该项目已移植到 Linux 和 Windows。现在需要一个 to_lower 功能。
在 POSIX 操作系统上,我可以使用 std::ctype_byname("ru_RU.UTF-8")。但是对于 g++(Debian 4.3.4-1), ctype::tolower() 不能识别俄语 UTF-8 字符(拉丁文本小写很好)。
在 Windows 上,当我尝试使用“ru_RU.UTF-8”参数构造 std::ctype_byname 时,mingw 的标准库抛出异常“std::runtime_error: locale::facet::_S_create_c_locale name not valid”。
如何在 Windows 上为 utf-8 实现/查找 std::ctype?该项目已经依赖于 libiconv(codecvt facet 基于它),但我没有看到用它实现 to_lower 的明显方法。