Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <locale>
- #include <vector>
- std::ostream & operator << ( std::ostream &os, const wchar_t * txt )
- {
- int new_size = WideCharToMultiByte( CP_UTF8, 0, txt, -1, NULL, NULL, NULL, NULL );
- if ( new_size <= 0 )
- return os;
- std::vector<char> buffer(new_size);
- WideCharToMultiByte( CP_UTF8, 0, txt, -1, &buffer[0], new_size, NULL, NULL );
- os << &buffer[0];
- return os;
- }
- /**/int main()
- {
- std::locale loc("fr_FR");
- std::cout << "User locale: " << loc.name() << std::endl;
- std::wstring str(L"àäâéèêëïîöôüû");
- std::cout << str.c_str() << std::endl;
- for(std::wstring::iterator it=str.begin();it!=str.end();++it)
- {
- *it = toupper(*it, loc);
- }
- std::cout << str.c_str();
- std::cout << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement