search
Homephp教程php手册phpword中文字符乱码解决办法

phpword中文字符乱码解决办法

Jun 13, 2016 am 09:57 AM
phpwordChineseGarbled characterspeopleintroducemanageMethodcharacterarticlesolve

本文章晋级人大家介绍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哦。反正我的显示中文了。在网上找了好久,研究了半天才搞定。

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

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

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Safe Exam Browser

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.