phpword中文字符乱码解决办法
本文章晋级人大家介绍phpword中文字符乱码解决办法,希望此文章对各位所有帮助哦。
最近领导要求用php生成word,网上找了很多类啊,函数啊。最终相中phpword。无奈不是国人开发,对中文支持很不友好。经过研究,终于解决了中文乱码,分享出来。
1、用模板word生成word中文乱码解决方案:
打开phpword/Template.php文件,找到$replace = utf8_encode($replace);将其改为$replace =iconv('gbk', 'utf-8', $replace); 即可。
2、直接生成word文档,调用addText对象时中文乱码解决方案:
打开phpword/Section.php文件,找到$givenText = utf8_encode($text);将其改为$givenText = iconv('gbk', 'utf-8', $text);即可。
3、貌似其他方法也类似第解决。
4、注意php文件采用gbk哦。反正我的显示中文了。在网上找了好久,研究了半天才搞定。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 English version
Recommended: Win version, supports code prompts!

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver Mac version
Visual web development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.
