Home >Backend Development >PHP Tutorial >Solution to garbled Chinese characters in phpword_PHP tutorial

Solution to garbled Chinese characters in phpword_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:57:261236browse

This article introduces the solution to garbled Chinese characters in phpword. I hope this article will be helpful to everyone.

Recently, the leader requested to use PHP to generate word, and I found many classes and functions on the Internet. Finally I fell in love with phpword. Unfortunately, it was not developed by Chinese people, and it is very unfriendly to Chinese support. After research, I finally solved the Chinese garbled code and shared it.

1. Use template word to generate Chinese garbled word solution:

Open the phpword/Template.php file, find $replace = utf8_encode($replace); change it to $replace =iconv('gbk', 'utf-8', $replace); and that's it.

2. Directly generate word documents and solve Chinese garbled characters when calling the addText object:

Open the phpword/Section.php file, find $givenText = utf8_encode($text); change it to $givenText = iconv('gbk', 'utf-8', $text);.

3. It seems that other methods have similar solutions.

4. Note that the php file uses gbk. Anyway, my display is in Chinese. I searched online for a long time and researched for a long time before I finally figured it out.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632089.htmlTechArticleThis article introduces the solution to garbled Chinese characters in phpword. I hope this article will be helpful to you. Recently, my boss asked me to use php to generate word. I found many categories on the Internet, functions...
Statement:
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