Strings with special characters in foreign language

How can I get the computer to cout in a foreign language such as spanish with ñ or german with ö, ä, ü and ß? if I cout these characters in a string, they r all fcked up. and instead have to actually pass the ascii character value, such as 132 for ä, or have a const char a_umlaut = 132.

so I can do something like this:

1
2
3
4

const char a_umlaut = 132;
cout << "H" << a_umlaut << "tte";


to cout the german word for 'had'
but not like this:

 
cout << "Hätte";


what gives? I find this incredibly anoying. Is it c++ in general or just codeblocks?
It's your terminal emulator.
If you are using cmd to display stdout, you'll have to set up the right code page
¿and how do I do that?
But if I do this char c = 'ñ' gcc yelds
warning: multi-character character constant
and c gets 177 instead of 241. It seems to be system dependent so everything after 127 converts to garbage
That depends on the encoding of your source files
Everything after 127 is not ASCII
Last edited on
could I define a macro (somehow) that would override the system whenever I type alt+132 it would instead of simply typing ä it would type " << a_umlaut << " ? ?
Maybe, but wouldn't it be easier to just type that, instead? Or you can use '\x84' or '\204'.

std::cout doesn't behave very well with non-ASCII. The results are heavily configuration-dependent.
Gee, why didn't I think of that?
Topic archived. No new replies allowed.