View difference between Paste ID: vmVUXVk6 and DgfeaKbG
SHOW: | | - or go back to the newest paste.
1
#include <iostream>
2
#include <locale>
3
#include <vector>
4
5
std::ostream & operator << ( std::ostream &os, const wchar_t * txt )
6
{
7-
    std::wcout << L"User locale: " << loc.name() << std::endl;
7+
  int new_size = WideCharToMultiByte( CP_UTF8, 0, txt, -1, NULL, NULL, NULL, NULL );
8
  if ( new_size <= 0 )
9-
    std::wcout << str << std::endl;
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-
       std::wcout << toupper(*it, loc);
13+
  return os;
14
}
15
16-
    std::wcout << std::endl;
16+
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
    }