在 php 和 javascript 之间传递 utf-8 字符串 [英] Passing utf-8 strings between php and javascript

查看:26
本文介绍了在 php 和 javascript 之间传递 utf-8 字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在将 utf-8 字符串传递给 javascript (ajax) 时遇到问题.目前我在 PHP 端使用 rawurlencode,在 javascript 端使用 unescape.

I'm having problems passing utf-8 strings to javascript (ajax). Currently i'm using rawurlencode on the PHP side and unescape on the javascript side.

问题在于拉丁语,rawurlencode 不完全支持它.

The problem is in latin and rawurlencode doesn't support it fully.

有没有其他选择或更好的选择?

Is there any alternative or any better option?

推荐答案

解决方案是在 json_encode 函数中.当我添加 JSON_HEX_APOS|JSON_HEX_QUOT 时,问题停止了.

The solution was in json_encode functions. The problems stopped when i added JSON_HEX_APOS|JSON_HEX_QUOT.

谢谢!

这篇关于在 php 和 javascript 之间传递 utf-8 字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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