3

Somehow my previous question has been marked as duplicate.

Question:

I have a database with records in Chinese characters. I can take them out, and use them in button.Text.

However, when I use

Console.WriteLine(button.Text);

The output displays every Chinese character as a "?"

Now, why is the question NOT duplicate? I have THOROUGHLY searched for a solution, not just on stackoverflow, on everywhere I can search (with my limited skills). Read all those related posts. I found two potential solutions:

One: Console.OutputEncoding = Encoding.Unicode; Unicode, UTF8, UT7, UTF32.

Two: Change my computer's locale in Control Panel to a region with Simplified Chinese. Then reboot and run the solution again.

I have tried both these suggested solutions, individually and together. Nothing works. The output changes from "?" to completely jibberish, unrecognizable characters.

Does anyone have any idea what to do here?

Momom0
  • 79
  • 1
  • 9
  • `I have a database with records in Chinese characters. I can take them out, and use them in button.Text.` - What do you mean by take them out? Are you sure you are correctly reading them back from the database? – Igor Apr 28 '16 at 19:43
  • The OP suggests he can put the text onto a Button so I think the question is just about outputting to a Console. @Momom0 - can you tell us the unicode value of a piece of text which is causing you a problem ? – PhillipH Apr 28 '16 at 19:48
  • You can show Simplified Chinese characters in the console by just going to your regional settings then change the "Language for non-Unicode programs" setting to Simplified Chinese after doing that you'll need to change the console's font to `Consolas` and that's it. [It works on my machine](http://i.imgur.com/qEMQJ6P.png) – Nasreddine Apr 28 '16 at 20:37
  • @Nasreddine can you tell me how to do that? where is this regional settings button? o.0 Thanks! – Momom0 Apr 29 '16 at 15:41
  • I'll post a more complete answer as soon as I'm near a computer. – Nasreddine Apr 29 '16 at 15:45

2 Answers2

2

This is a more complete version of my comment. The way I was able to display Simplified Chinese characters was by changing the language of Non-Unicode programs to Chinese:

Changing the language of Non-Unicode programs to Chinese

Then in the cmd properties set the font to Consolas

enter image description here

I didn't even need to set the Console.OutputEncoding. This is the result (these are Chinese characters copy/pasted from the internet):

enter image description here

Nasreddine
  • 36,610
  • 17
  • 75
  • 94
0

I think this is a duplicate of How to write Unicode characters to the console? which indicates that although .net and Unicode support your characters, the Font you are using as the output font of the Console does not support that Unicode character.

Your post does not indicate that you have tried adjusting the Console Font.

Community
  • 1
  • 1
PhillipH
  • 6,182
  • 1
  • 15
  • 25
  • This should be a comment or a vote to close with a comment. – Nasreddine Apr 28 '16 at 19:55
  • I dont think it is - the OP might reject my answer as not being correct and continue to seek a better solution. Just voting for a close on my assumption that my answer must surely be correct for the OP is a bit arrogant wouldnt you say ? – PhillipH Apr 28 '16 at 19:57
  • The answer is a duplicate of the one you linked to (which also mentions the need of a font change). Same goes for OP's question. – Nasreddine Apr 28 '16 at 20:01
  • How do you know it solves the OPs problem, until they confirm it has. – PhillipH Apr 28 '16 at 20:02
  • [Just tried it on my machine and it works](http://i.imgur.com/qEMQJ6P.png).it's missing the part where you should update the language for non unicode programs to Simplified Chinese in the windows regional settings. – Nasreddine Apr 28 '16 at 20:40
  • So, going to drop the "Close with Comment" or upvote my correct answer ? :-) – PhillipH Apr 28 '16 at 21:40
  • Oh yeah, forgot to mention, another thing I tried, Tools--> Options-->Environment--> Fonts and Colors... Where I made all text tool windows have a Chinese font, NSimsun :C didn't work either – Momom0 Apr 29 '16 at 15:20
  • I'M loosing hope here, :C BUT, thank you guys so much for the help! – Momom0 Apr 29 '16 at 15:23