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
In daily maintenance, threads are often blocked, ...
Preface binlog is a binary log file, which record...
With the development of Internet technology, user...
Table of contents defineComponent overload functi...
This article example shares the specific code of ...
Table of contents First, let's briefly introd...
1. Check whether the MySQL service is started. If...
Table of contents Block-level functions Directly ...
I joined a new company these two days. The compan...
Table of contents Global Registration Partial Reg...
This article shares the specific code of JS to ac...
Inside the style tag of the vue component, there ...
Preface This article mainly introduces 4 methods ...
The previous article explained how to reset the M...
Preface Take Element Plus as an example to config...