Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Unicode (Japanese Characters)

Tags:

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!

like image 899
Hassaan M Avatar asked Dec 09 '09 03:12

Hassaan M


People also ask

What C is used for?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

What is the full name of C?

In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr. Stroustroupe.

Is C language easy?

C is a general-purpose language that most programmers learn before moving on to more complex languages. From Unix and Windows to Tic Tac Toe and Photoshop, several of the most commonly used applications today have been built on C. It is easy to learn because: A simple syntax with only 32 keywords.

Is C programming hard?

C is more difficult to learn than JavaScript, but it's a valuable skill to have because most programming languages are actually implemented in C. This is because C is a “machine-level” language. So learning it will teach you how a computer works and will actually make learning new languages in the future easier.


2 Answers

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

like image 96
YOU Avatar answered Oct 12 '22 10:10

YOU


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.

like image 30
SamB Avatar answered Oct 12 '22 11:10

SamB