9

I've read in several places that boost::algorithm::to_upper/to_lower are not ok for 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

Community
  • 1
  • 1
Daniel Pinyol
  • 2,094
  • 2
  • 15
  • 15
  • 2
    So... do you have a question? – Xymostech Mar 12 '13 at 22:32
  • The linked Boost page gives an example and explanation where `boost::algorithm::to_upper_copy` gives an incorrect result... – aschepler Mar 12 '13 at 22:44
  • @aschepler That's because in the example they don't pass any locale to the boost::algorithm functions. With the locale I do get the capital "Ü". – Daniel Pinyol Mar 12 '13 at 23:10
  • 6
    No, the mistake is that the uppercase of "ß" is "SS", not "ß". But since `boost::algorithm::to_lower` returns a single code point, there's no way to fix that without using an algorithm which outputs strings. – aschepler Mar 12 '13 at 23:15
  • 1
    @aschepler: +1, but your comment should have been an answer. – dalle Jun 09 '13 at 20:49
  • @aschepler Thanks, actually there's also a ẞ (slightly different than ß), but SS is the correct way. I haven't found any other case in "typical languages", though. – Daniel Pinyol Jun 13 '13 at 09:20

0 Answers0