conversion of a single wchar_t with toupper

K

kmw

Hi,

I have no idea what I am doing wrong. The following piece of code
should work but it does not. Any ideas?

Output is:
T
T
?
?

#include <locale>
#include <string>

int main ( )
{
std::locale loc ( "en_US.UTF-8" );
//std::locale loc ( "de_DE.utf8" ); // I also tried this
std::wcout.imbue ( loc );
std::wcout << std::toupper<wchar_t> ( L't', loc ) << L'\n';
std::wcout << std::use_facet< std::ctype<wchar_t> >(loc).toupper
( L't' ) << L'\n';
std::wcout << std::toupper<wchar_t> ( L'ä', loc ) << L'\n';
std::wcout << std::use_facet< std::ctype<wchar_t> >(loc).toupper
( L'ä' ) << L'\n';
return 0;
}

Many thanks ind advance,
Kay
 
R

Ralf Goertz

kmw said:
Hi,

I have no idea what I am doing wrong. The following piece of code
should work but it does not. Any ideas?

Assuming you use g++ and you include iostream, the aswer is to add

std::ios_base::sync_with_stdio(false);

at the beginning of main.
 
K

kmw

Great! That does the trick. Many thanks.

Assuming you use g++ and you include iostream, the aswer is to add

std::ios_base::sync_with_stdio(false);

at the beginning of main.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,961
Messages
2,570,131
Members
46,689
Latest member
liammiller

Latest Threads

Top