json编码€符号 [英] json encoding € symbol

查看:142
本文介绍了json编码€符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个php页面,该页面生成从mysql表中提取值的json. 一切都很好,除非我的值包含欧元符号(例如€20,00"),欧元符号在我的json中显示为\ u20ac ...

I have a php page generating json extracting values from a mysql table. Everything is fine except where I have values containing euro symbol (like "€ 20,00") the euro symbol show up in my json as \u20ac...

赞:

[
  {
    "id": "535",
    "Name": "Pluto",
    "fare": "\u20ac 20,00"
  }
]

在评估此json的页面中,它显示为€20,00",这很好,但是我真的希望它在json字符串本身中也显示相同的内容.

In the page evaluating this json it appears as "€ 20,00", so this is fine, but I really would like it to appear the same also in the json string itself.

有任何提示吗?

推荐答案

多字节可以-只要不是控制字符-可以按字面显示或以\uXXXX进行转义,并且两种表示形式都是正确的.如果您更喜欢文字表示形式,并且使用php创建json,则需要将正确的选项传递给

Multibyte can - as long as they are not control characters - be displayed literally or escaped as \uXXXX and both representations are correct. If you prefer the literally representation and if you use php to create the json then you need to pass the correct options to json_encode: Parameters

您要查找的选项是 JSON_UNESCAPED_UNICODE :

按字面意义编码多字节Unicode字符(默认为转义为\ uXXXX).自PHP 5.4.0起可用

Encode multibyte Unicode characters literally (default is to escape as \uXXXX). Available since PHP 5.4.0

这篇关于json编码€符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆