Skip to content

Instantly share code, notes, and snippets.

@feng-ming
feng-ming / utf8_detect.php
Last active December 13, 2015 20:28
检测文件是否是UTF-8编码。 转换非UTF-8编码的文件到UTF-8编码
<?php
//检测字符串是否是utf-8编码
if(mb_detect_encoding($content,"UTF-8, ISO-8859-1, GBK, gb2312") !== 'UTF-8')
{
$content = iconv("gbk","utf-8",$content);
}
//转换文件为utf-8编码的文件,如果该文件开始即为utf-8,则不会做任何处理
enca -L zh_CN -x UTF-8 $script_dir/../upload/text/$1.txt
/*!
* jQuery Tiny Pub/Sub - v0.6 - 1/10/2011
* http://benalman.com/ see https://gist.github.com/661855
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*
* (removed pre 1.4.3 support, added $.pubsubdebug())
*/