doukui9491 2017-02-28 13:27
浏览 78
已采纳

欧元符号显示为\ u00e2 \ u00ac \ u00ac和â€

I know there are a lot of topics out there concerning this problem, but I've spend the last hours trying various approaches an I'm nowhere close to the solution. So here it goes ...

This is my jquery:

$.post('inc/app_json_f.php',{params:priv_params}, function (data) {
  console.log(data);
  // displays: \u00e2\u0082\u00ac instead of €
  data = JSON.parse(data);
  console.log(data);
  // displays: â¬â¬ instead of €
}

This is my php (the app_json_f.php page):

$qry = 'select ... from ... where ...';
$data = $db->do_select($qry);

echo json_encode(f_utf8_json($data));

The f_utf8_json function will check the $data and convert every value with utf8_encode().

At this moment, the echo json_encode(...) will display the following in the console:

\u00e2\u0082\u00ac

Whereas I would like to see the € sign.

The data comes from a MySQL database which has collation utf8_general_ci. PHP's charset is UTF-8.

Any suggestions?

  • 写回答

3条回答 默认 最新

  • douxuzui4590 2017-03-03 09:19
    关注

    By removing the f_utf8_json function (the one that converts the values to utf8 with utf8_encode()), everything works ok. Strange, because I added this function earlier in the project because it was necessary to get the right results. I have to double check, but possibly another database setting was the cause of this.

    Problem solved.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 怎样才能让鼠标沿着线条的中心线轨迹移动
  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?