Need help on unicode in VisualC++

This is a discussion on Need help on unicode in VisualC++ within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Im trying to get cout to understand swedish characters, anyone know howto? If I prompt the user to write to ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    10

    Need help on unicode in VisualC++

    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!

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    72
    hi
    just use the L prefix for your unicode text constants e.g.

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

    damyan

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    10
    Thanks, but I have tried that , but it prints all swedish characters like carbage.

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    72
    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";

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    10
    Thank YOU

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. <string> to LPCSTR? Also, character encoding: UNICODE vs ?
    By Kurisu33 in forum C++ Programming
    Replies: 7
    Last Post: 10-09-2006, 12:48 AM
  2. Unicode - a lot of confusion...
    By Jumper in forum Windows Programming
    Replies: 11
    Last Post: 07-05-2004, 07:59 AM
  3. Should I go to unicode?
    By nickname_changed in forum C++ Programming
    Replies: 10
    Last Post: 10-13-2003, 11:37 AM
  4. UNICODE and windows.h help
    By nextus in forum Windows Programming
    Replies: 3
    Last Post: 03-02-2003, 02:13 PM
  5. UNICODE and GET_STATE
    By Registered in forum C++ Programming
    Replies: 1
    Last Post: 07-15-2002, 03:23 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21