How to display Chinese characters in the graphics function of PHP.

Source: Internet
Author: User
Tags format chr php file
function | Chinese Characters | graphics | display <?php
/******************************
How to display Chinese characters in PHP graphics function, we have been asking for a long time, but there has been no results. Finally in the reference to another article, I tried it out!
Method:
First, decide which characters to display, such as the "counter" three words.
To Word2000 (97 do not know), enter the three words, save As, select the encoding format, and then on the right side of the encoding type to select Unicode Utf-8, remember not to choose the wrong. A text file that is stored in a coded format, such as a file named Test.txt.
Open this file with a 16-in editor, and you'll see that there's a stack of 16 characters in it and a Chinese character for three bytes, so here you should find the 9 bytes in front and write it down.
To start editing the. php file, write it down in the format of Chr (0xe6). Chr (0x88), then assign to a variable, then output with the Imagettftext () function. What did you see?
If you do not see anything, then you need to look at the 16 of your code is correct, of course, display the font files required for Chinese characters you have to copy to the appropriate location Oh! My program uses the italics that Windows brings.
But this is still very troublesome, after all, also need to use the other two tools, if can have a function directly to convert Chinese characters to Utf-8 code is better. Let's look for more information!

This string of utf-8 strings means "I love you!" "Hee, 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);
?>


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.