Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# windows form cannot display simplified Chinese characters

Tags:

c#

unicode

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?

like image 402
Momom0 Avatar asked Nov 26 '25 22:11

Momom0


1 Answers

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

like image 124
Nasreddine Avatar answered Nov 28 '25 11:11

Nasreddine



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!