0

I'm trying to upgrade legacy system to PHP 5.5.38 from PHP 5.3.3. I read data from db and write to file and process the file. When using PHP 5.3.3 (PHP ini default charset latin or utf8), the encoding chars(non-english chars) works fine but when using PHP 5.5.38, the encoding chars does not work well.

I changed RDS db configuration params character-set-server = latin1 in staging server, the encoding works fine.

Production RDS MYSQL DB configuration

mysql> show variables like "%character%";
+--------------------------+-----------------------------------------------------------------+
| Variable_name            | Value                                                           |
+--------------------------+-----------------------------------------------------------------+
| character_set_client     | utf8                                                            |
| character_set_connection | utf8                                                            |
| character_set_database   | utf8                                                            |
| character_set_filesystem | binary                                                          |
| character_set_results    | utf8                                                            |
| character_set_server     | utf8                                                            |
| character_set_system     | utf8                                                            |
| character_sets_dir       | /rdsdbbin/oscar-5.6.mysql_aurora.1.19.2.0.157.0/share/charsets/ |
+--------------------------+-----------------------------------------------------------------+

but contents in table is using latin chars. When I view the text in mysql client I see this

บริà¸à¸²à¸£ Model clip หน้าใหม่เด็ดๆ คิดเงิน 5บ. ดู

PHP 5.3.3 using PEAR version: 1.9.4

PHP 5.5.38 using PEAR version: 1.10.12

I don't understand what causes this issue? How it works in PHP 5.3.3 but not in PHP 5.5.38 (not using htmlspecialchars) after reading the data from DB, just write it to file.

I checked PEAR change log but I couldn't find anything related to charset.

Thanks in advance.

Rajesh
  • 3
  • 2
  • I found something in php 5.3.3, when I run this query $this->db->query("select charset('')"); it returns array(1) { ["charset('')"]=> string(6) "latin1" } but in php 5.5.38 array(1) { ["charset('')"]=> string(4) "utf8" } not sure, why? I use this option to update the charset using PEAR query $this->db->query("set names latin1"); – Rajesh Nov 03 '20 at 13:03
  • Is part of that Thai for `หน้าให`? See "Mojibake" in https://stackoverflow.com/questions/38363566/trouble-with-utf8-characters-what-i-see-is-not-what-i-stored – Rick James Nov 04 '20 at 20:12

0 Answers0