boost::algorithm::to_upper/to_lower ok for utf8? boost::locale not necessary?

痴心易碎 提交于 2019-12-08 19:08:04

问题


I've read in several places that boost::algorithm::to_upper/to_lower are not ok for utf8:

  • http://www.boost.org/doc/libs/1_51_0/libs/locale/doc/html/conversions.html
  • How to convert std::string to lower case?
  • Working with UTF8

But on my system, ubuntu 12.4.1 32 bits with boost 1.46, and locale en_GB.UTF-8, everything looks fine,as long as I pass the locale Eg:

std::locale englishUTF8locale("en_GB.UTF-8")
boost::algorithm::to_upper_copy(L"ü", englishUTF8locale) -> L"Ü"
boost::algorithm::to_lower_copy(L"и", englishUTF8locale) ->L"И"

What is worth noting is that it works when using std::wstring, but not when using std::string

So, boost::locale is not really necessary? My problem is that I can only use boost 1.46, and locale was created for 1.48

来源:https://stackoverflow.com/questions/15373510/boostalgorithmto-upper-to-lower-ok-for-utf8-boostlocale-not-necessary

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!