I’m writing an app that is database driven through network.request() calls to PHP scripts on the server side.
This works remarkably well, but I’ve having problems with special characters. After setting the database string fields to use utf8_general_ci (with phpMyAdmin) and calling set_charset(“utf8”) in the PHP scripts, I’m able to transfer special characters (specifically norwegian Æ, Ø & Å characters) to the database where they apparently are stored correctly.
But I’m struggling the other way. Fetching the strings from the database with json_encode results in “garbage”.
Typically a simplified version of my PHP looks something like this:
$result = mysqli\_query($conn, $sql); if ($result) { if ($result-\>num\_rows \> 0) while ($row = $result-\>fetch\_assoc()) $retValJSON[]=$row; } else { formExit($conn, "db\_error"); } echo json\_encode(utf8ize($retValJSON));
The receiving end (network listener in the app) looks roughly like this:
local function getMyItemsNetworkListener(event) if ( event.isError ) then print( "Network error!") else myNewData = event.response decodedData = (json.decode(myNewData)) getMyItemsCB(decodedData) end end
Any idea how I can get to my special characters?