The actual contents are like this:
I tried these: https://stackoverflow.com/a/23179613/13865853
in model.php
if (mysqli_num_rows($result) > 0) {
//iterate
while($row = mysqli_fetch_assoc($result)){
//get username
$disease = mb_convert_encoding($row['disease'], "UTF-8", "auto");
$food = mb_convert_encoding($row['food'], "UTF-8", "auto");
$en_name = mb_convert_encoding($row['en_name'], "UTF-8", "auto");
$health_effect = mb_convert_encoding($row['healthEffect'], "UTF-8", "auto");
$metabollite = mb_convert_encoding($row['metabollite'], "UTF-8", "auto");
//$citation = $row['citation'];
$next_row = array("Disease"=>$disease, "Food"=>$food,
"Name"=>$en_name, "Health Benefits"=>$health_effect, "Metabollite"=>$metabollite);
//"Sources"=>$citation);
$matches_arr[] = $next_row;
}
}
$utfArr = array_map("utf8_encode", $matches_arr);//this does not work for associate arrays I think
back in controller.php I tried again
//encode in UTF8
foreach($matches_arr as $col => $val){
$utf8_val = mb_convert_encoding($val, "UTF-8", "auto");
$matches_arr[$col] = $utf8_val;
}
//send it back to view
header('Content-Type: application/json');
$disease_json = json_encode($matches_arr, JSON_UNESCAPED_UNICODE);
echo $disease_json;
but it outputs question marks for table columns in Japanese:
I saw this: https://stackoverflow.com/a/30826067/13865853
But I think my case is different because mysql database is already encoded in utf8mb4_bin
and not an obscure Japanese encoding.
Anyways from that answer I tried putting this tag at the top of controller.php and model.php
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />"
and check that my view.php has the charset:
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
<meta name="generator" content="Jekyll v4.1.1">
<title>Dashboard Bioactive Compounds</title>
<!-- boostrap comes first -->
<link rel="stylesheet" href="css/bootstrap.css">
<meta charset="utf-8">
Actually it had it twice.
I saw that the query result in model.php is already just question marks in phpstorm debugger console when I inspect the query result variable.
How can I fix this to show Japanese on the view page?