5

I have a Japanese final coming up soon, so to help me study I made a program to help me study. But, I can't seem to get VS2008 to display any Unicode in the Console. This is a sample I used to see if I could display Unicode:

    string diancai = new string(new char[]{ '\u70B9','\u83DC' });

    Console.Write(diancai[0] + " " + diancai[1]);

Output is:

    ? ?

Please help! Thank you!

Makoto
  • 104,088
  • 27
  • 192
  • 230
Hassaan M
  • 51
  • 1
  • 1
  • 2

3 Answers3

3

Go to your command prompt and try a command "chcp"

It should be like this

C:\> chcp
現在のコード ページ: 932

932 is japanese, If code page is not correct or if your windows does not support, It can't display it in console.

I can run yours in mine, its display following chars, mine is japanese windows.

点 菜

So, For your case, I recommand you to try with GUI program instead of console

YOU
  • 120,166
  • 34
  • 186
  • 219
  • I did it and this was the result: C:\> chcp Active code page: 437 Any chance I can change it to 932? – Hassaan M Dec 09 '09 at 03:44
  • Try `chcp 932`, and try copy paste "点 菜", if you can't see that, its mean you cannot do that. try with GUI. – YOU Dec 09 '09 at 03:46
  • OH I see...Umm this might be too much to ask, but can you please give me a sample code, showing me how to display characters using a GUI window? This is my first time programming in C# and my final is coming up soon. – Hassaan M Dec 09 '09 at 03:48
  • And I've been searching for an answer all day today with no luck. – Hassaan M Dec 09 '09 at 03:48
  • I prsume you're using an english version of Wondows? it doesn't work here either... – RCIX Dec 09 '09 at 03:55
  • Yeah, its mean, your windows doesnot support it, for GUI, In Visual C# windows, there is option for New Project for `C# Windows Applications`, So just go ahead and try it, I assumed you know C# Language itself. – YOU Dec 09 '09 at 03:56
  • so there is no way of using UTF8 in console? im trying with this word: "Đức" but it's not working – DucDigital Feb 06 '10 at 15:14
2

There are two conditions that must be satisfied in order for this to work:

  1. The console's output encoding must be able to represent Japanese characters
  2. The console's font must be able to render them

Condition 1 should be fairly simple to deal with; just set System.Console.OutputEncoding to an appropriate Encoding, such as a UTF8Encoding. (Of course, this won't work on Windows 9x, since that doesn't really support encodings or Unicode. But you aren't using that, now, are you?)

Satisfying condition 2 is a bit more involved:

  1. First, an appropriate font must be installed on the user's system. If there aren't any installed yet, the user will have to install some, perhaps by:

    • Opening intl.cpl ("Regional and Language Options" in the Control Panel on Windows XP in English)
    • Going to the "Languages" tab
    • Enabling "Install files for East Asian languages"
    • Clicking "OK"
  2. Actually getting the console to use such a font seems to be fairly hairy; see the question: How to display japanese Kanji inside a cmd window under windows? for more about that.

Community
  • 1
  • 1
SamB
  • 9,039
  • 5
  • 49
  • 56
1

I use Windows XP english version. But I set my OS so it can show Japanese characters.

For Windows XP this is the step:

1.Control Panel -> Regional and Language Options -> Advanced

2.Choose Japanese.

3.Choose code page conversion tables for language do you use.

4.Push OK button

5.Restart your computer.

I tried to use "chcp" command on command prompt.

It display: Active code page 932

vic
  • 440
  • 1
  • 4
  • 10