Display Chinese characters in PHP graphic functions

Source: Internet
Author: User
Tags chr php file
You have been asking how to display Chinese characters in PHP graphic functions for a long time, but there has been no result. After finally referring to another article, I tried it!
Method:
First, determine the Chinese characters to display, such as the "counter.
Enter these three words in Word2000 (97), save them as, select the encoding format, and then select unicode UTF-8 in the right encoding type. Remember not to select the wrong one. Save it as a local file, such as test.txt.
Open this file in a hex editor, and you will see a heap of hexadecimal characters in it. One Chinese character occupies three bytes. So here, you should find the content of the first nine bytes and write it down.
Edit the. Php file, write it in the format of chr (0xE6). chr (0x88), assign it to a variable, and then output it using the ImageTTFText () function. What do you see?
If you haven't seen anything, you need to check whether your hexadecimal code is correct. Of course, you need to copy the font files needed to display Chinese characters to a proper location! In this program, I use the built-in fuse body in windows.
However, this is still very troublesome. After all, another two tools are required. If you can use a function to convert Chinese characters to UTF-8 encoding, it would be better. Let's look for more information!
The UTF-8 string represents "I love you !", Hey, 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 );
$ Blue = ImageColorAllocate ($ im, 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 );
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.