The boost to_upper function from string_algo does not take into account the locale

I have a problem with functions in string_algo package.

Consider this piece of code:

#include <boost/algorithm/string.hpp>
int main() {
   try{
      string s = "meißen";
      locale l("de_DE.UTF-8");
      to_upper(s, l);
      cout << s << endl;
   catch(std::runtime_error& e){
      cerr << e.what() << endl;
   }

   try{
      string s = "composición";
      locale l("es_CO.UTF-8");
      to_upper(s, l);
      cout << s << endl;
   catch(std::runtime_error& e){
      cerr << e.what() << endl;
   }
}

Expected result for this code:

MEISSEN
COMPOSICIÓN

however the only thing i get is

MEIßEN
COMPOSICIóN

therefore, obviously, language is not taken into account. I am even trying to establish a global language without success. What can I do?

+3
source share
4 answers

std :: toupper accepts a 1: 1 conversion, so there is no hope for the case of ß over SS, Boost.StringAlgo or not.

StringAlgo, , ( Borland, ). , : toupper('ó', std::locale("es_CO.UTF-8")) ?

, - : ? UTF8? std:: toupper '-', . Latin1? ".UTF-8" .

+1

- std::locale . , std::wstring - , convertd, , , ( ß).

Boost.Locale( , boost),

http://cppcms.sourceforge.net/boost_locale/docs/,

http://cppcms.sourceforge.net/boost_locale/docs/index.html#conversions, , .

+3

std:: toupper ( boost:: to_upper), .

, ß . , , , .

, wstring?

0
source

You can use boost :: locale. Here is an example.

0
source

Source: https://habr.com/ru/post/1723465/


All Articles