开发者

What to do to be sure to get a UTF-8 encoded string back independent from the encoding of the input in PHP

Is there a way to encode any string with any encoding into UTF-8?

Is there some native function in PHP?

Or is there some function free to use?

I had the problem that if 开发者_如何转开发I utf8_encode() a UTF-8 encoded string I get some double encoded thing which is useless.

I need to encode any incoming string, if it's Unicode, UTF-16, ISO..something, etc... into simple UTF-8. (Well, it would be good, if the function detects whether it's a string or not before manipulating it.)


function as_utf8($s)
{
    return mb_convert_encoding($s, "UTF-8", mb_detect_encoding($s));
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜