Display Chinese characters in the C program

zhaozj2021-02-17  54

In many C programming, you should use the Chinese characters to prompt or human-computer interaction, and the current Turbo C integrated development environment is not Chinese, how to develop C procedures that can display Chinese characters? The following method can help you show Chinese characters in the Western environment. This method is to call the Chinese Chinese word library for Chinese characters. National Standards: The Chinese customs is divided into 94 districts, and 94 Chinese characters in each zone (in place are different), each Chinese is determined in the Chinese graph library, which is the location code of Chinese characters. Each Chinese character is stored in a dot pattern in the library, which is generally 16 × 16-point array (32 bytes), 24 × 24 o'clock (72 bytes), each point with a binary bit (0 or 1) Representation, the corresponding Chinese character is displayed on the screen. Due to the Chinese environment, the internal code of Chinese characters, we must convert it into a zone code, calculate the offset, find the corresponding Chinese characters from the franchis, and display it.

The internal code conversion to the zone code method is as follows: QH = C1-0XA0 WH = C2-0XA0 its location code is: Qw = QH * 0xFF Wh this Chinese word in the font is: Offset = (94 * (QH-1) (WH-1)) * 32L program: #include #include #include #include #include #include < Conio.h> #define row 1 // Sedimentation Multifiance #define col 2 // Sands Multifilt Void Main () {Int x, Y; Char * S = "Chinese Character Display"; File * fp; char buffer [32]; // buffer is used to store a Chinese character Register M, N, I, J, K; Unsigned char qh, wh; unsigned long offset; int GD = Detect, GM; // Graphics screen Initgraph (& GD, & GM , ""); If (fp = fopen ("hzk16", "rb")) == null) // Open the Chinese character library, the font can find {printf in UCDOS ("Can't Open HAZ16, PLEASE ADD IT "); getCH (); closegraph (); exit (0);} x = 20; y = 100; // Display position setting while (* s) {qh = * (s) -0xa0; // Chinese character location Code WH = * (S 1) -0xa0; Offset = (94 * (QH-1) (WH-1)) * 32L; // Calculate the deviation in the word library FSeek (fp, offset, seek_set); FREAD (Buffer, 32, 1, FP); // Take out the word 32 byte of the Chinese characters in the buffer (one Chinese character) for (i = 0; i <16; i ) // Print the 32-bit byte of the dot matrix in the screen (1: Print, 0: Do not print), display the Chinese character for (n = 0; n > (7-

转载请注明原文地址:https://www.9cbs.com/read-29820.html

New Post(0)