Php uses the Gd library to add Garbled text watermarks and solutions,
Recently a project for server migration, deployment found that one of the image to add watermark text function garbled problem, confirm that the function code is not a problem, while the project code is using UTF-8 encoding, there is no encoding problem, and the check also ruled out the possibility of a problem with the font file. After finally checking the information, the php compilation parameter -- enable-gd-jis-conv is locked.
-- Enable-gd-jis-conv:
If the-enable-gd-jis-conv option is enabled during PHP compilation, non-ASCII characters (such as Chinese characters, Pinyin, Greek and arrows) are treated as EUC-JP encoding, eventually, normal Chinese characters become garbled characters.
Solution:
1. Remove the -- enable-gd-jis-conv option and re-compile php
2. Convert characters to html Objects
Mb_convert_encoding ('test', 'html-ENTITIES ', 'utf-8 ');