Wei Dongshan Embedded Getting Started Notes-Application Development Fundamentals (7)

Chapter 6 Text Display

6.3 Dot matrix display of Chinese characters

Source code:
04_Basic knowledge of embedded Linux application development\source\09_show_chinese\
test_charset_ansi.c
test_charset_utf8.c
show_chinese.c

6.3.1    Specify encoding format
When using dot matrix fonts, the display principle of Chinese characters is the same as that of ASCII characters. The place to pay attention to is the Chinese encoding: in the C source file, is its encoding method GB2312 or UTF-8? Is the Chinese character encoding in the compiled executable program GB2312 or UTF-8?

1. Generally , UTF-16 encoding is not used. In this way, ASCII characters are also represented by 2 bytes, and one of the bytes is 0. However, in C language, 0 represents the end of the string. Cause misunderstanding. 

2. When we write C programs, we can use ANSI encoding or UTF-8 encoding

  • When compiling the program, you can use the following options to tell the compiler:
    If you do not specify "-finput-chars et", GCC will default to the encoding of C programs as UTF-8, even if you save in ANSI format, it will be Treat it as UTF-8.
  • For the compiled executable program, you can specify how the characters in it are encoded, and you can use the following options compiler:
    If you do not specify "-fexec-charset", GCC will default to the characters in the compiled executable program The encoding method is UTF-8. 
  • If "-finput-charset" is different from "-fexec-charset", the compiler will perform format conversion.

 

To be perfected

 

Guess you like

Origin blog.csdn.net/San_a_fish_of_dream/article/details/113836529