开发者

PHP Json_Encode strange characters?

开发者 https://www.devze.com 2023-01-22 10:37 出处:网络
I am using J开发者_Go百科SON_ENCODE in PHP to output data. When it gets to this word: Æther it outputs \\u00c6ther.

I am using J开发者_Go百科SON_ENCODE in PHP to output data. When it gets to this word: Æther it outputs \u00c6ther.

Anyone know of a way to make json output that character or am I going to have to change the text to not have that character in it?


That's the unicode version of the character. JavaScript should handle it properly. You'll notice the slash before it which means that it's an escape sequence. The u indicates it's a unicode code point and the hex digits represent the actual character.
See here for some more info.


That is working as specified. The RFC ( http://www.ietf.org/rfc/rfc4627.txt ) indicates that any character may be escaped, and your average printable character can be written in the \uXXXX format.

Any JSON parser that cannot understand a character escaped in that way is not compliant with the standard. Work on resolving that problem rather than trying to coax PHP into misbehaving as well.

(It is legal to put UTF-8 characters into JSON strings without escaping them as well, with a few exceptions, but the safe approach of escaping anything questionable is wise.)

0

精彩评论

暂无评论...
验证码 换一张
取 消