Displaying Chinese characters in PHP graphics functions_PHP tutorial

WBOY
Release: 2016-07-21 16:10:25
Original
834 people have browsed it


Everyone has been asking how to display Chinese characters in PHP graphics functions for a long time, but there has been no result. Finally, after referring to another article, I tried it out!
Method:

First, decide which Chinese characters you want to display, such as the three words "counter".
Go to Word2000 (97, I don’t know if it is possible), enter these three words, save as, select the encoding format, and then select unicode utf-8 in the encoding type on the right. Remember not to make the wrong choice. Save it as a text file in an encoded format, for example, the file name is test.txt.

Open this file with a hexadecimal editor. You will see that there are a bunch of hexadecimal characters in it. Each Chinese character occupies three bytes, so here, you should find the first 9 characters. Byte content, write it down.

Start editing the .php file again, write it in a format such as chr(0xE6).chr(0x88), assign it to a variable, and then use the ImageTTFText() function to output it. What did you see?

If you don’t see anything, then you need to check again to see if your hexadecimal codes are correct. Of course, you also need to copy the font files needed to display Chinese characters to the appropriate location! In this program, I use the regular script that comes with Windows.

However, this is still very troublesome. After all, two other tools are needed. It would be better if there was a function that directly converts Chinese characters into UTF-8 encoding. Let’s look for more information!

This string of utf-8 strings means "I love you!" Hehe, don't say I'm disgusting!

******************************/
$cur_count=chr(0xE6).chr( 0x88).chr(0x91).chr(0xE7).chr(0x88).chr(0xB1).chr(0xE4).chr(0xBD).chr(0xA0).chr(0xEF).chr(0xBC).chr( 0x81);
Header("Content-type: image/gif");
$im = imagecreate(156,116);
$black = ImageColorAllocate($im, 0,0,0);
$blue = ImageColorAllocate($im, 0,0,255);
$white = ImageColorAllocate($im, 255,255,255);
$yellow = ImageColorAllocate($im, 255,255,0);
ImageTTFText($ im,20,0,4,40,$yellow,"simkai.ttf",$cur_count);
ImageGif($im);
ImageDestroy($im);
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/314268.htmlTechArticleHow to display Chinese characters in PHP graphics functions. Everyone has been asking for a long time, but there has been no result. Finally, after referring to another article, I tried it out! Method: First, decide what you want to...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template