Advertisement
Guest User

Untitled

a guest
Apr 28th, 2012
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <locale>
  3. #include <vector>
  4.  
  5. std::ostream & operator << ( std::ostream &os, const wchar_t * txt )
  6. {
  7.   int new_size = WideCharToMultiByte( CP_UTF8, 0, txt, -1, NULL, NULL, NULL, NULL );
  8.   if ( new_size <= 0 )
  9.     return os;
  10.   std::vector<char> buffer(new_size);
  11.   WideCharToMultiByte( CP_UTF8, 0, txt, -1, &buffer[0], new_size, NULL, NULL );
  12.   os << &buffer[0];
  13.   return os;
  14. }
  15.  
  16. /**/int main()
  17.     {
  18.     std::locale loc("fr_FR");
  19.     std::cout << "User locale: " << loc.name() << std::endl;
  20.     std::wstring str(L"àäâéèêëïîöôüû");
  21.     std::cout << str.c_str() << std::endl;
  22.  
  23.     for(std::wstring::iterator it=str.begin();it!=str.end();++it)
  24.        {
  25.        *it = toupper(*it, loc);
  26.        }
  27.     std::cout << str.c_str();
  28.     std::cout << std::endl;
  29.  
  30.     return 0;
  31.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement