微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

修复PHP中的字符

任何人都知道这是什么以及如何解决它? “OMG”

<p>After 32 years in its former location, this popular restaurant 
   and bar moved to the bottom of the Avalon Bay Luxury residential building 
   that's just a walk from Angel Stadium. Modern and welcoming, the expansive 
   space is where fans, locals and families gather for upscale twists on classic
   American dishes. Burgers here have a decidedly fun flair like “The OMG� 
   that is a burger surely meant for sharing (with many)--it's so huge that it's 
   served on a 14-inch bun. The restaurant also specializes in seafood with such 
   items as Chilean sea bass, mahi mahi and swordfish. The lounge also serves 
   signature drinks like  the Rally Monkey Martini in tribute to the mascot 
   of the Angels.</p>

这似乎是一个问题,因为我必须在解码它之前运行JSON数据或JSON解码失败的函数

function safeJSON_chars($data) {
$aux = str_split($data); 
foreach($aux as $a) { 
    $a1 = urlencode($a); 
    $aa = explode("%", $a1); 
    foreach($aa as $v) { 
        if($v!="") { 
            if(hexdec($v)>127) { 
            $data = str_replace($a,"&#".hexdec($v).";",$data); 
            } 
        } 
    } 
} 
return $data;}

解决方法:

看看这个页面

Unicode-friendly PHP and MySQL

在此页面上,您将找到一个简单明了的UTF-8编码说明,以及如何在您的网站中应用它以及一些实际示例.

您还需要确保使用UTF-8编码(无BOM)保存文件.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐