乌秋博客
梦想在左,生活在右。   

PHP & JavaScript: UTF-16 to UTF-8
外国的一个blog上摘录的,原文如下:

Recently I’ve been doing some work on a PHP script that has to process a bunch of XML files (in this case they’re imsmanifest files) however a few of them weren’t being parsed successfully.

The problem was soon quite clear, some of the files had been encoded using UTF-16 which wasn’t playing nicely with PHP. To solve this I’ve written a function that attempts to detect if a string is encoded using UTF-16 (little endian or big endian) and then converts it to a slightly more PHP friendly UTF-8. All the complicated stuff is copied from these JavaScript functions for converting between UTF-8 and UTF-16.


PHP:


JavaScript:

原文地址:
http://www.moddular.org/log/utf16-to-utf8
posted at 07/03/07 17:03 | 技术文摘 - PHP | 浏览(80) | 引用 | 评论(2)

 Track this back : http://www.koven.org/rserver.php?mode=tb&sl=208
Commented by 叶青 at 07/03/08 08:39 x
英文不行诶,,,,

Commented by koven at 07/03/08 09:56 x
为何英文不行?我也是照原文抄录的……

  name   password   homepage
隐藏评论(只有管理员可见)    


      << prev    1  ...  176  177  178  179  180  181  182  183  184  ...  336    next >>