php 繁体字转化为简体字_Ruby_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > Ruby > php 繁体字转化为简体字

php 繁体字转化为简体字

 2011/1/2 10:31:48  xiaoyangok  http://xiaoyangok.javaeye.com  我要评论(0)
  • 摘要:1.php加载mbstringextension=php_mbstring.dll2.配置mbstring[mbstring];languageforinternalcharacterrepresentation.;http://php.net/mbstring.languagembstring.language=Chinese;internal/scriptencoding.;Someencodingcannotworkasinternalencoding.;(e.g.SJIS,BIG5
  • 标签:PHP 繁体字转化为简体字


1.php加载mbstring

extension=php_mbstring.dll

2.配置mbstring

[mbstring]
; language for internal character representation.
; http://php.net/mbstring.language
 mbstring.language = Chinese

; internal/script encoding.
; Some encoding cannot work as internal encoding.
; (e.g. SJIS, BIG5, ISO-2022-*)
; http://php.net/mbstring.internal-encoding
 mbstring.internal_encoding =UTF-8

; http input encoding.
; http://php.net/mbstring.http-input
 mbstring.http_input = auto

; http output encoding. mb_output_handler must be
; registered as output buffer to function
; http://php.net/mbstring.http-output
mbstring.http_output = UTF-8

; enable automatic encoding translation according to
; mbstring.internal_encoding setting. Input chars are
; converted to internal encoding by setting this to On.
; Note: Do _not_ use automatic encoding translation for
;       portable libs/applications.
; http://php.net/mbstring.encoding-translation
 mbstring.encoding_translation = On





3.我的代码:

function fantigetjianti($str) {
    $fantis = "";
    include "fanti2jiantiData.php";   //加载繁体字数组
    for ($i = 0; $i <= mb_strlen($str); $i++) {
        $fanti = mb_substr($str, $i, 1);
        $jianti = $fantiData[$fanti];
        if (empty($jianti)) {
            $jianti = $fanti;
        }
        $fantis .=$jianti;
    }
    return $fantis;
}




发表评论
用户名: 匿名