Solve the problem of Chinese garbled characters in the graphical interface of Zabbix monitoring system caused by adding the -enable-gd-jis-conv option in compiling PHP Phenomenon: PHP compilation parameters: illustrate: If PHP is compiled with the --enable-gd-jis-conv option enabled, non-ASCII characters (such as Chinese characters, Pinyin, Greek and arrows) will be treated as EUC-JP characters (called "JIS-encoded fonts" in phpinfo), resulting in garbled characters (since Western fonts have no kana or Chinese characters, they are generally displayed as all boxes). The imagettftext() function is used to write characters into a picture. This problem is caused by this function. I have checked several incomplete tutorials on the Internet. The following is my production practice operation, in zabbix3.2 version, php7.2 version Method 1: Recompile and install PHP, disabling the -enable-gd-jis-conv option. This method is more expensive. Method 2: Because the production environment PHP has been used for a long time, I don't know if there are any applications using it, so I dare not recompile it easily, so I solve it according to method 2 first step: Modify the function to_entities($string){ $len = strlen($string); $buf = ""; for($i = 0; $i < $len; $i++){ if (ord($string[$i]) <= 127){ $buf .= $string[$i]; } else if (ord ($string[$i]) < 192) { //unexpected 2nd, 3rd or 4th byte $buf .= "?"; } else if (ord ($string[$i]) < 224) { //first byte of 2-byte seq $buf .= sprintf("&#%d;", ((ord($string[$i + 0]) & 31) << 6) + (ord($string[$i + 1]) & 63) ); $i += 1; } else if (ord ($string[$i]) < 240) { //first byte of 3-byte seq $buf .= sprintf("&#%d;", ((ord($string[$i + 0]) & 15) << 12) + ((ord($string[$i + 1]) & 63) << 6) + (ord($string[$i + 2]) & 63) ); $i += 2; } else { //first byte of 4-byte seq $buf .= sprintf("&#%d;", ((ord($string[$i + 0]) & 7) << 18) + ((ord($string[$i + 1]) & 63) << 12) + ((ord($string[$i + 2]) & 63) << 6) + (ord($string[$i + 3]) & 63) ); $i += 3; } } return $buf; } Step 2: Find the imagettftext() function in the file (three places in total) Change the last parameter $string to Summarize The above is the method I introduced to you to solve the problem of garbled Chinese characters in the graphical interface of Zabbix monitoring due to PHP problems. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: How to capture exceptions gracefully in React
>>: Optimize the storage efficiency of BLOB and TEXT columns in InnoDB tables
1. HTML Overview htyper text markup language Hype...
Purpose Understand the role of nextTick and sever...
Background Recently, when writing SQL statements,...
1. Unzip nginx-1.8.1.tar.gz 2. Unzip fastdfs-ngin...
HTML implements 2-column layout, with fixed width...
At the very beginning, let's talk about what ...
Table of contents Why update the auto-increment i...
Table of contents Loop - for Basic use of for loo...
Table of contents 0. The kernel tree that comes w...
After creating a container locally, you can creat...
Table of contents Get the content of the iframe o...
1. Installation apt-get install mysql-server requ...
Ubuntu install jdk: [link] Install Eclipse on Ubu...
Table of contents Preface 1. What are Mixins? 2. ...
In relational databases, pessimistic locking and ...