search
HomeBackend DevelopmentPHP ProblemWhat to do if the Chinese text watermark in PHP is garbled

Solution to garbled Chinese text watermark in php: 1. Remove the "--enable-gd-jis-conv" option and recompile php; 2. Convert characters to html entities through "mb_convert_encoding".

What to do if the Chinese text watermark in PHP is garbled

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

php uses the Gd library to add garbled text watermarks Problems and solutions

Recently a project underwent server migration. After deployment, it was discovered that one of the functions of adding watermark text to pictures had garbled problems. Confirm that there is no problem with the function code, and at the same time the project code They all use UTF-8 encoding, and there is no encoding problem. We also checked and ruled out the possibility of problems with the font file. Finally, after consulting the information, we locked a PHP compilation parameter --enable-gd-jis-conv.

--enable-gd-jis-conv:

If the –enable-gd-jis-conv option is enabled when compiling PHP, then non-ASCII characters (such as Chinese characters, pinyin, Greek and arrows) will be regarded as EUC-JP encoding, which will eventually lead to normal Chinese characters become garbled

Solution:

1. Remove the --enable-gd-jis-conv option and recompile php

2 .Convert characters to html entities

mb_convert_encoding ('测试', 'HTML-ENTITIES', 'UTF-8');

[Recommended learning: "PHP Video Tutorial"]

The above is the detailed content of What to do if the Chinese text watermark in PHP is garbled. For more information, please follow other related articles on the PHP Chinese website!

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 Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

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

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.