前言:

當時網域名稱系統(DNS)設計時,沒有人想到會有中文網址的需求,所以當時網址只接受 ASCII
隨著時代進步,在2003年的時候,開始發展出國際化域名(IDN)
所謂國際化域名就是包含非ASCII文字的網域名稱
為了相容性,於是開發了一個叫做 Punycode 的演算法,例如 xn--fiq228c
特性是都已 xn-- 開頭,該標準定義於 RFC 3492 當中

現成 PHP Function:

解碼:

string idn_to_utf8 ( string $domain [, int $options = 0 [, int $variant = INTL_IDNA_VARIANT_2003 [, array &$idna_info ]]] )

idn_to_unicode :為 idn_to_utf8 的 alias

編碼:

string idn_to_ascii ( string $domain [, int $options = 0 [, int $variant = INTL_IDNA_VARIANT_2003 [, array &$idna_info ]]] )

 

或是參考網友寫的:

https://code.google.com/p/punycode-library/source/browse/punycode.php

http://ckon.wordpress.com/2010/08/24/punycode-to-unicode-converter-php/

http://www.xarg.org/project/php-idna/

arrow
arrow
    全站熱搜

    AwEi 發表在 痞客邦 留言(0) 人氣()