编码问题

WBOY
Release: 2016-06-23 14:13:56
Original
1045 people have browsed it

$url  ="http://www.amazon.co.jp/dp/B007HDJPOU"; $handle=mb_convert_encoding(file_get_contents($url), 'UTF-8','utf-8, shft-jis, gbk');$sumopen=fopen("001.txt","w");fwrite($sumopen,$handle);fclose($sumopen);
Copy after login


这段代码把代码存入txt文件,现在日文部分全是乱码,请问怎么样不会乱码

??????涔?/span>
????????/span>



???????????



回复讨论(解决方案)

本来就是shift-jis编码,没转换

他有



mb_convert_encoding(file_get_contents($url), 'UTF-8','utf-8, shft-jis, gbk');
是不是写错了?

只能把页面编码改成Shift_JIS??

你写的是什么?
'UTF-8','utf-8, shft-jis, gbk'

xuzuning大大,已经改过来了

输出的文件还是乱码

 $handle=mb_convert_encoding(file_get_contents($url), 'UTF-8','utf-8, shft_jis, gbk');$sumopen=fopen("001.txt","w");fwrite($sumopen,$handle);fclose($sumopen);
Copy after login


另外还有一个问题,请问为什么时候我获取的源码跟在浏览器的不一样

$handle=mb_convert_encoding(file_get_contents($url), 'UTF-8','utf-8,  shift_jis, gbk');

再想了一下,感觉是编码已经转换了
问题应该出在写入文件上,改成这个试试
$sumopen=fopen("001.txt","w b");

就是按字节输出,你打开这个txt要选无bom utf-8打开

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template