本文介绍了PHP URL编码/解码跨表单字段的%u2019的漂亮行情的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

由于某种原因,在将这样的字符串 Jack's Spindle 从文本表单提交给PHP后,我会得到:

For some reason, after submitting a string like this Jack’s Spindle from a text form to php, I get:

Jack%u2019s Spindle

这是不是什么PHP的 urlencode()会做,这将是 Jack%92s + Spindle
rawurlencode ) = Jack%92s%20 Spindle

This is not what PHP's urlencode() would do, which would be Jack%92s+Spindleor rawurlencode() = Jack%92s%20Spindle

因此, urldecode(),原始版本不能解码该字符串...这样的字符串是否有另一个功能?

Thus, urldecode() and the raw version don't work to decode that string... Is there another function for such strings?

-

另外, Jack&#8217的s Spindle 将是HTML安全的编码上述方式,但是 urlencode()和原始*表示:杰克%26%238217%3Bs +主轴杰克%26%238217%3Bs%20主轴分别...

Also, Jack’s Spindle would be the HTML-safe way to encode the above, but urlencode() and raw* for that yields: Jack%26%238217%3Bs+Spindle and Jack%26%238217%3Bs%20Spindle respectively...

%u2019 来自?它代表什么?你如何让它回到那个无耻的撇号?

Where is the %u2019 coming from? What does it represent? How do you get it back to just that innoculous apostrophe?

推荐答案

嗯,只有你可以告诉我们从哪里来。你从哪里得到你的文本,哪些转换是提交给?我承认我还没有看到编码策略。

Well, only you can tell us from where that came from. From are you getting your text and which transformations is it being submitted to? I confess I haven't seen that encoding strategy yet.

这就是说,它与Javascript编码UTF-16代码单元的方式非常相似: \uXXXX 其中每个 X 表示十六进制字符。要将其转换为HTML实体,您可以执行以下操作:

That said, it's very similar to the way Javascript encodes UTF-16 code units: \uXXXX where each X represents a hexadecimal character. To convert it to HTML entities, you could do:

preg_replace('/%u([a-fA-F0-9]{4})/', '&#x\\1;', $string)

这篇关于PHP URL编码/解码跨表单字段的%u2019的漂亮行情的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 17:23