I'm trying to read from a database and show the result in a TextView in Android, it works until there is a Swedish letter in the sentence, otherwise the TextView shows null. In the database everything is ok, even the Swedish letters work perfect there, but the problem is in the Android.
I'm using UTF-8 in Android and utf8-general-ci for the database column.
Edit: This PHP function solved my problem
/* Change data-type from string to integar or float if required.
* If string detected then utf8_encode() it. */
function cast_data_types ($value) {
if (is_array($value)) {
$value = array_map('cast_data_types',$value);
return $value;
}
if (is_numeric($value)) {
if(strpos('.', $value)===false) return (float)$value;
return (int) $value;
}
return utf8_encode((string)$value);
}
json_encode (cast_data_types($data));