醉爱PHP

PHP关于GBK下针对中文的替换全角空格

by admin on 九.10, 2008, under php

对于我来说,这是一个难题,屹今为止,我还没有找到解决方法。所以先发到日志里,容日后灵光现的时候,或者能找到解决方法。

问题是这样的:在GBK编码下,要把这个全角的空格替换掉而不会出现乱码。每字节循环判断是可以做到的。但效率低,所以我也不写这个丑陋的方法了。

字符串是这样的:“我的单元测验”

echo str_replace(’’, ”, ‘我的单元测验’); //在GBK的编码存储下,这样的替换会出现乱码。

:

1 Comment for this entry

  • bin

    我还遇到这个问题了,不过我替换的时候不会出现乱码,只是不会替换。
    用正则替换的时候会乱码,替换也不成功

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...