Doubt about Unicode

This is a discussion on Doubt about Unicode within the C++ Programming forums, part of the General Programming Boards category; Assuming a very simple program that: -ask a name. -store the name in a variable. -display the variable content on ...

  1. #1
    Dox
    Dox is offline
    Registered User
    Join Date
    Jun 2010
    Posts
    1

    Doubt about Unicode

    Assuming a very simple program that:

    -ask a name.
    -store the name in a variable.
    -display the variable content on the screen.


    It's so simple that is the first thing that one learns.

    But my problem is that I dont know how to do the same thing if I enter the name using japanese characters.

    So, if you know how to do this, please show me an example (that I can compile and test)

    Thanks.

  2. #2
    Registered User
    Join Date
    Mar 2010
    Posts
    109
    Look up information on multibyte character sets. You will need wide characters to store the data, unlike ASCII which can store any character in the set inside of 1 byte. It's not a very straightforward issue, so I think you will need to do some reading.

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,671
    >> I dont know how to do the same thing if I enter the name using japanese characters.
    There's not much you have to do. For C, just call setlocale(LC_ALL, ""). This use the users default locale, which includes character encoding. For Japanese, the single byte encoding will be either UTF8 or Shift-JIS (codepage 932 on Windows).

    For C++, you would call "cin.imbue(locale(""))".

    gg

  4. #4
    Registered User
    Join Date
    Mar 2009
    Posts
    399
    As long as you don't modify the byte stream you get as input, it should display the same when you print it back to the terminal.

    Reading text in one encoding and displaying it in another is an entirely different thing though. For that I suggest iconv.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. RichEditCtrl & unicode formatted text
    By ddonate in forum Windows Programming
    Replies: 0
    Last Post: 03-26-2010, 10:50 AM
  2. <string> to LPCSTR? Also, character encoding: UNICODE vs ?
    By Kurisu33 in forum C++ Programming
    Replies: 7
    Last Post: 10-09-2006, 12:48 AM
  3. Unicode - a lot of confusion...
    By Jumper in forum Windows Programming
    Replies: 11
    Last Post: 07-05-2004, 07:59 AM
  4. Should I go to unicode?
    By nickname_changed in forum C++ Programming
    Replies: 10
    Last Post: 10-13-2003, 11:37 AM
  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