sirjo66 Well-Known Member Licensed User Longtime User Jul 20, 2014 #1 Hello to all, I am developing an APP that needs to read datas from a MySQL database and I am using some PHP script in the PC server for to read datas from the table and then the result is send to B4A in JSON format. All works fine, but when in a field there is a string with UTF-8 char, it don't work The problem isn't B4A, but is that PHP don't work properly. I have found the solution, I need to use this command in PHP script: Code: Copy echo json_encode($myarray, JSON_UNESCAPED_UNICODE); but it works only on PHP version 5.4 and upper, and my servers are running with version 5.3.xx and I can't update it How can do it ?? And when I solve the problem, and the string "papà" is send as "pap\uxxxx", B4A will work properly ??? Thanks Sergio
Hello to all, I am developing an APP that needs to read datas from a MySQL database and I am using some PHP script in the PC server for to read datas from the table and then the result is send to B4A in JSON format. All works fine, but when in a field there is a string with UTF-8 char, it don't work The problem isn't B4A, but is that PHP don't work properly. I have found the solution, I need to use this command in PHP script: Code: Copy echo json_encode($myarray, JSON_UNESCAPED_UNICODE); but it works only on PHP version 5.4 and upper, and my servers are running with version 5.3.xx and I can't update it How can do it ?? And when I solve the problem, and the string "papà" is send as "pap\uxxxx", B4A will work properly ??? Thanks Sergio
Spinter Active Member Licensed User Longtime User Jul 20, 2014 #2 prova a guardare il mio magari puo aiutarti try to look at my maybe can help you http://www.b4x.com/android/forum/threads/app-login-con-mysql.26498/#post153375 Upvote 0
prova a guardare il mio magari puo aiutarti try to look at my maybe can help you http://www.b4x.com/android/forum/threads/app-login-con-mysql.26498/#post153375
sirjo66 Well-Known Member Licensed User Longtime User Jul 21, 2014 #3 Found the problem !! The MySQL database is encoded by utf8_general_ci, but when I execute a query, the datas is in ISO-8859-1 Why ?? Sergio Upvote 0
Found the problem !! The MySQL database is encoded by utf8_general_ci, but when I execute a query, the datas is in ISO-8859-1 Why ?? Sergio
Shahid Saeed Active Member Licensed User Longtime User Jul 21, 2014 #4 sirjo66 said: Found the problem !! The MySQL database is encoded by utf8_general_ci, but when I execute a query, the datas is in ISO-8859-1 Why ?? Sergio Click to expand... You must save the PHP/JSON File in to UTF-8 without BOM. You will have file Encoding Option while saving the file within your PHP Editor. Upvote 0
sirjo66 said: Found the problem !! The MySQL database is encoded by utf8_general_ci, but when I execute a query, the datas is in ISO-8859-1 Why ?? Sergio Click to expand... You must save the PHP/JSON File in to UTF-8 without BOM. You will have file Encoding Option while saving the file within your PHP Editor.
sirjo66 Well-Known Member Licensed User Longtime User Jul 21, 2014 #5 My PHP script is already in UTF-8 without BOM format, but the problem is the same Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Jul 21, 2014 #6 It is not related to the PHP file encoding. There are several places you need to check. Use PhpMyAdmin to check the server settings and add this line to your script: Code: Copy mysql_query("SET CHARACTER SET utf8"); Upvote 0
It is not related to the PHP file encoding. There are several places you need to check. Use PhpMyAdmin to check the server settings and add this line to your script: Code: Copy mysql_query("SET CHARACTER SET utf8");
sirjo66 Well-Known Member Licensed User Longtime User Jul 21, 2014 #7 It works !! Many many thanks Sergio Upvote 0