php-注釋一段PHP代碼,能翻譯成C#最好

來源:互聯網
上載者:User
關鍵字 php
php

 function pinyin($s, $isfirst = false) {    static $pinyins;    $s = trim($s);    $len = strlen($s);    if($len < 3) return $s;    if(!isset($pinyins)) {        $data = '一:yi|丁:ding|丂:kao|七:qi|丄:shang|丅:xia|丆:mu|萬:wan|丈:zhang|三:san|上:shang|下:xia|丌:ji|不:bu|與:yu|丏:mian|丐:gai|醜:chou|丒:chou|專:zhuan|且:qie|丕:pi|世:shi|丗:shi|丘:qiu|丙:bing|業:ye|叢:cong|東:dong|絲:si|丞:cheng|丟:diu|丠:qiu|両:liang|丟:diu|丣:you|兩:liang|嚴:yan|並:bing|喪:sang|丨:gun|丩:jiu|個:ge|丫:ya|爿:zhuang|中:zhong|丮:ji|丯:jie|豐:feng|丱:guan|串:chuan|丳:chan|臨:lin|丵:zhuo|丶:zhu|丷:ha|丸:wan|丹:dan|為:wei|主:zhu|丼:jing|麗:li|舉:ju|丿:pie|乀:fu|乁:yi|乂:yi|乃:nai|乄:wu|久:jiu|乆:jiu|乇:tuo|麼:me|義:yi|乊:ho|之:zhi|烏:wu|乍:zha|乎:hu|乏:fa|樂:le|乑:yin|乒:ping|乓:pang|喬:qiao|乕:hu|乖:guai|乗:cheng';        $a1 = explode('|', $data);        $pinyins = array();        foreach($a1 as $v) {            $a2 = explode(':', $v);            $pinyins[$a2[0]] = $a2[1];        }    }    $rs = '';    for($i = 0; $i < $len; $i++) {        $o = ord($s[$i]);        if($o < 0x80) {            if(($o >= 48 && $o <= 57) || ($o >= 97 && $o <= 122)) {                $rs .= $s[$i]; // 0-9 a-z            }elseif($o >= 65 && $o <= 90) {                $rs .= strtolower($s[$i]); // A-Z            }else{                $rs .= '_';            }        }else{            $z = $s[$i].$s[++$i].$s[++$i];            if(isset($pinyins[$z])) {                $rs .= $isfirst ? $pinyins[$z][0] : $pinyins[$z];            }else{                $rs .= '_';            }        }    }    return $rs;}
  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.