Phpword Chinese character garbled solution

Source: Internet
Author: User

Recently, leaders asked php to generate word. They found many classes and functions online. Phpword in the final phase. It is not developed by Chinese people, and it is unfriendly to Chinese support. After research, we finally solved Chinese garbled characters and shared them.

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

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

2. Generate a Word document directly and call the addText object to solve Chinese garbled characters:

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

3. It seems that other methods are similar to the solution.

4. Pay attention to using gbk for PHP files. My display is Chinese. I have been searching for it online for a long time, and I have been studying it for a long time.

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.