Chinese characters in the Western environment

zhaozj2021-02-12  148

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 into a zone code method is as follows:

QH = C1-0XA0 WH = C2-0xa0

Its location code is:

Qw = QH * 0xFF WH

The location of the Chinese word in the font is:

OFFSET = (94 * (QH-1) (WH-1)) * 32L

Example:

#Include

#Include

#Include

#Include

#Include

#Include

#DEFINE ROW 1 // Collapse a large number of

#Define col 2 // Torched

void main ()

{

INT X, Y;

Char * s = "Chinese Character Display Procedure";

File * fp;

Char buffer [32]; // buffer is used to store a Chinese character

Register M, N, I, J, K;

Unsigned char qh,.

unsigned long offset;

INT GD = Detect, GM; // Graphics screen initialization

INITGRAPH (& GD, & GM, ");

IF ((fp = fopen ("hzk16", "rb") == null)

// Open the Chinese character library, the franchery can be found in UCDOS

{Printf ("Can't Open Haz16, please");

GetCh (); closegraph (); exit (0);

}

X = 20; y = 100; // Display position setting

While (* s)

{QH = * (s) -0xa0; // Chinese zone bit code

WH = * (S 1) -0xa0;

OFFSET = (94 * (QH-1) (WH-1)) * 32L; // Calculate the deviation of the Chinese in the font

FSeek (fp, offset, seek_set);

Fread (buffer, 32, 1, fp); // Take out the word of the Chinese characters 32 bytes to store into buffer (a Chinese character)

For (i = 0; i <16; i ) // Print 32-bit bytes of dot matrix in the screen (1: Print, 0: Do not print), display Chinese characters

FOR (n = 0; n

For (j = 0; j <2; j )

For (k = 0; k <8; k ) for (m = 0; M

IF ((Buffer [i * 2 j] >> (7-k)) & 0x1)! = NULL)

PUTPIXEL (X 8 * J * COL K * COL M, Y I * ROW N, GREEN);

S = 2; // Because a Chinese character is occupied by two bytes, S must add 2

X = 30;

}

Getch ();

Closegraph ();

}

The above program runs successfully under the Turbo C 2.0 compilation system, which enlarges Chinese characters. The reader can change it to a function to display Chinese characters in your program.

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

New Post(0)