-
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.
-
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.
-
>> 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
-
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.