具有特殊字符(例如é)的json [英] json with special characters like é

查看:99
本文介绍了具有特殊字符(例如é)的json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery,PHP和JSON作为响应来开发依赖选择脚本.

I'm developing a dependent select script using jQuery, PHP and JSON as the response.

除了使用特殊字符(如法语(é,è,à...))之外,一切都很好

Everything goes well except for using special characters like French ones (é , è , à...)

如果我像(& eacute;,& egrave;和& agrave;)那样对它们进行预编码(在这里,我在&号和单词的其余部分之间使用空格,以防止在我的问题中自动编码)它可以工作,但是当使用jquery渲染时,字符不会转换为应显示的样子(é...),而是按原样显示(& eacute;)

if I pre-encode them like (é , è , à) (Here I'm using spaces between the ampersand and the rest of the word to prevent auto encoding in my question) it works but when rendered with jquery the characters are not converted to what they should look like (é...), instead they are shown as is (é)

如果我将它们写为(é)并且不对其进行预编码,则不会显示此数组条目中的完整值.

If I write them like (é) and don't pre-encode them the full value in this array entry is not shown.

我应该在这里做什么?

谢谢.

推荐答案

就像第一个弓箭手一样

您使用数据库吗?如果是,请确保将数据库表声明为UFT8 如何声明HTML页面? UTF-8 字符串在PHP脚本文件中吗?如果是,请确保文件具有UTF-8文件格式

Do you use a database? If Yes, make sure the database table is declared UFT8 How is declared the HTML page? UTF-8 IS the string in the PHP script file? If yes, make sure the file has a UTF-8 file format

您还可以使用utf8_encode(发送到HTML)和utf8_decode(接收),但方法不正确

You could also use utf8_encode (to send to HTML) and utf8_decode (to receive) but not the right way

这篇关于具有特殊字符(例如é)的json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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