Keil C51 Chinese Garbled Code Issue

Keil C51 Chinese Garbled Code Issue

Recently, I have encountered the issue of Chinese garbled text in the compiler. Although it does not affect the execution of the program, it always feels awkward to see a bunch of garbled text. I have a bit of OCD and always want to fix it!

Keil C51 Chinese Garbled Code Issue

The reason for this problem is that everyone uses different document encoding methods when developing programs.

For example, in the past two days, I opened a header file for the SJA1000, and it displayed like this.

Keil C51 Chinese Garbled Code Issue

All you need to do is select the encoding method in KEIL to solve the problem.

Keil C51 Chinese Garbled Code Issue

You can see that it displays correctly!

Keil C51 Chinese Garbled Code Issue

However, another problem arises. For example, if the program I originally wrote uses UTF-8 encoding and I need to add a file encoded in ANSI, I can’t just disregard the other files for the sake of this file displaying correctly. So what should I do?

Actually, it’s very simple. Just find a file conversion software to convert it. Which one should I use? It’s quite simple; the Notepad on our computer is a very simple tool that can achieve this functionality.

For example, use Notepad to open your file.

Keil C51 Chinese Garbled Code Issue

Then, just change the encoding when saving it.

Keil C51 Chinese Garbled Code Issue

Display both files in KEIL to compare and find that we have achieved our expected requirement, converting an ANSI encoded document to a UTF-8 document.

Keil C51 Chinese Garbled Code Issue

The same applies in reverse.

Keil C51 Chinese Garbled Code IssueKeil C51 Chinese Garbled Code Issue

Leave a Comment