Display principle of GD Chinese characters. Here we will share with you the principle of displaying Chinese in GD. I believe you can write it out after reading it. The GD Library in PHP is actually supporting Chinese, but it must be in UTF-8 format here to tell you about the Chinese display GD principle. I believe you can write it out after reading it.
The GD Library in PHP is actually supporting Chinese, but must be passed in UTF-8 format parameters, you can experiment with the following small program.
You will be able to see the "Chinese OK" figure. (
UTF-8: Unicode Transfer Format 8 is a compatible representation of Unicode)
Header ("Content-type: image/gif ");
$ Im = imagecreate (400,300 );
$ Bkg = ImageColorAllocate ($ im, 0, 0 );
$ Clr = ImageColorAllocate ($ im, 255,255,255 );
$ Fnt = "c:/winnt/fonts/simhei. ttf ";
// If 98/95 "c:/windows/fonts/simhei. ttf ";
$ Str = chr (0xE4 ). chr (0xB8 ). chr (0xAD ). chr (0xE6 ). chr (0x96 ). chr (0x87 ). "OK ";
// "OK Chinese" in UTF-8ImageTTFText ($ im, 20, 0, 10, 20, $ clr, $ fnt, $ str );
ImageGif ($ im );
ImageDestroy ($ im);?>
If you only want to display a fixed Chinese string, you can in the Word, four-way cube and other software to display the character to the UTF-8 format, and then paste into the program can be. If you want to dynamically display the corresponding Chinese characters according to the user input, it is necessary to solve the problem of converting the Chinese characters to the UTF-8 format.
I am not very clear about Chinese processing in UNIX/Linux, there is no say, if it is a Unicode internal code, it should be converted to the UTF-8 format.
If GBK internal code is used like Win95/98, it should be first converted to Unicode and then converted to UTF-8 format.
For GBK-Unicode conversion, I used a very stupid solution, which is proposed here for your discussion. I hope you can propose a simpler and more efficient solution.
I first use this applet to display all GBK characters, and then convert it to Unicode in Word. Convert each character to a corresponding Unicode value based on this string. The process of Unicode representation as a UTF-8 references the conversion program cvtutf. c, cvtutf. h on Unicode.
$ I <= 0xFE; $ I ++ ){
// 0x81-0xFE
For ($ j = 0x40; $ j <= 0xFE; $ j ++ ){
// 0x40-0x7E 0x80-0xFE
If ($ j! = 0x7F ){
Echo chr ($ I). chr ($ j );
}}}?>
Bytes. I believe you can write it out after reading it. The GD Library in PHP actually supports Chinese, but it must be in UTF-8 format...