Home  >  Article  >  Backend Development  >  求解乱码难题解决方案

求解乱码难题解决方案

WBOY
WBOYOriginal
2016-06-13 10:15:261319browse

求解乱码难题

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->/***   给出一段乱码,如何求出原文..*   疑问是,无论是什么字符,unicode总应该都能显示出来.能否转成unicode编码达到效果.*/$str = 'manufacturering 12鈥? 16鈥? 20鈥? 24鈥? 36鈥?48鈥? 60, 72", 84",96",120" sphere, Various styles';//求解....


------解决方案--------------------
在这里一粘贴,全都变了
你需要给出原始的数据,必要时用 base64_encode 编一下码
------解决方案--------------------
mb_convert_encoding函数可以不指明原字符集只指定目标字符集来完成转换,它会自动检测(但不一定可靠)
------解决方案--------------------
全部使用utf-8吧。连文件编码都要使用。
------解决方案--------------------
额。。这个 我也不知道了 等高人解答。。。
毕竟一般的转换都是知道原字符集的,如果实在不知道。。。。只能挨个尝试?
------解决方案--------------------
这段二进制数据所表示的实际文本的字符集,目前来看是不确定的。。

一切皆有可能,往跑偏了说是BIG5也不一定。

虽然unicode, utf8等字符集可以兼容任意语言的文字,但要将这段数据可以转换为utf8等字符集 仍然需要知道原字符集是什么。
------解决方案--------------------
探讨

引用:

在这里一粘贴,全都变了
你需要给出原始的数据,必要时用 base64_encode 编一下码


无论怎么变,这些字符的二进制数据应该没有变吧.也就是说它们应该对应一种字符编码才能正确显示.可是我不晓得怎么转变编码。

------解决方案--------------------
不过可以猜出大概


// 鈥
/*
for($i=0x80; $ifor($j=0x60; $jecho iconv('gbk', 'utf-8', chr($i).chr($j)) . ",$i $j ";
*/
foreach(array(170,172,173,174,175,176,177,228,228,235,249) as $n)
echo chr(161).chr($n);
/*
—‖…‘’“”′′‰※
*/

根据上下文,为 ” 的可能性最大
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn