gpt4 book ai didi

PHP URLDecode/UTF8_Encode 字符集特殊字符问题

转载 作者:可可西里 更新时间:2023-11-01 00:26:26 25 4
gpt4 key购买 nike

我将英镑符号 £ 传递给一个 PHP 页面,该页面已被 ASP URL 编码为 %C2%A3

问题:

urldecode("%C2%A3") // £
ord(urldecode("%C2%A3")) // get the character number - 194
ord("£") // 163 - somethings gone wrong, they should match

这意味着当我执行 utf8_encode(urldecode("%C2%A3")) 我得到 £

但是 utf8_encode("£") 我得到了预期的 £

我该如何解决这个问题?

最佳答案

我不认为 ord() 是多字节兼容的。它可能只返回字符串中第一个字符的代码,即 Â。在对字符串调用 ord() 之前尝试对其进行 utf8_decode(),看看是否有帮助。

ord(utf8_decode(urldecode("%C2%A3"))); // This returns 163

关于PHP URLDecode/UTF8_Encode 字符集特殊字符问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5550309/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com