PDA

View Full Version : Need help on unicode in VisualC++



codewarrior
10-09-2001, 06:28 AM
Im trying to get cout to understand swedish characters, anyone know howto?
If I prompt the user to write to cin.getline(), and then write it to the std.output it works fine.

Like this:
char str[30];
cin.getline(str, 30);
cout << str;

But if I assign a constant C-string to a variable, and try cout, it doesnt show the right characters.

Like this:
char str[30] = "something with swedish characters";
cout << str;

I have tried with wcout and wchar_t, but it doesnt help, any help is greatly apreciated.
TIA!

damyan
10-09-2001, 10:28 AM
hi
just use the L prefix for your unicode text constants e.g.

wchar_t str[30] = L"something with swedish characters";

damyan

codewarrior
10-10-2001, 06:06 AM
Thanks, but I have tried that , but it prints all swedish characters like carbage.

damyan
10-10-2001, 10:30 AM
Hi
another way to avoid it is to use the escape sequences instead of the actual characters that don't print correctly.

e.g.
\206
\204
\224

char * someText = "som\206thing wit\204 wird chars in it";

codewarrior
10-10-2001, 12:57 PM
Thank YOU