Android Question PHP and JSON

sirjo66

Well-Known Member
Licensed User
Longtime User
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:
B4X:
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
 

sirjo66

Well-Known Member
Licensed User
Longtime User
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

Shahid Saeed

Active Member
Licensed User
Longtime User
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
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

Well-Known Member
Licensed User
Longtime User
My PHP script is already in UTF-8 without BOM format, but the problem is the same
 
Upvote 0
Top