I'm using the following code to get JSON from a page and parse it to my HTML page. The JSON is not being displayed in UTF-8 and therefore has weird characters. How can I remove the weird characters?
$.get("test.php", function (data) {
var JSON = jQuery.parseJSON(data);
$.each(JSON.deals.items, function (index, value) {
// My code
});
});
Please make sure that every single step of your process is in UTF-8:
The content-type headers that you output
header('Content-Type: application/json; charset=utf-8');
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Refer to: PHP json_encode json_decode UTF-8
EDIT: If you already have weird characters like \u00a3
in your JSON feed instead of the £
symbol, your problem has already been answered: https://stackoverflow.com/questions/1423846/convert-unicode-from-json-string-with-php