PHP
downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

intl> <idn_to_ascii
Last updated: Fri, 30 Jan 2009

view this page in

idn_to_utf8

(PECL idn >= 0.1)

idn_to_utf8Convert ASCII encoded domain name to UTF-8

説明

string idn_to_utf8 ( string $ascii_domain [, int &$errorcode ] )

This function converts a ASCII encoded domain name to its original UTF-8 version.

パラメータ

ascii_domain

The ASCII encoded domain name. Looks like "xn--..." if the it originally contained non-ASCII characters.

errorcode

Will be set to the IDNA error code.

返り値

The UTF-8 encoded version of the domain name or FALSE in case of an error. RFC 3490 4.2 states though "ToUnicode never fails. If any step fails, then the original input sequence is returned immediately in that step."

エラー / 例外

If an error occurs FALSE is returned and the optional errorcode is set. In addition a E_WARNING message is printed.

例1 idn_to_utf8() example

First a simple example and then one explaining how to catch errors (which should never happen according to the RFC).

<?php

// maybe convert the result to ISO-8859-1 using utf8_decode()
echo idn_to_utf8("xn--tst-qla.de");

// Should never happen but to be sure...
$utf8 idn_to_utf8("xn--tst-qla.de"$errorcode);
if (
$utf8 === false) {
    
printf("Detected error %d: %s\n"$errorcodeidn_strerror($errorcode));
}

?>

上の例の出力は、たとえば 以下のようになります。

täst.de

参考

  • utf8_decode() - UTF-8 エンコードされた ISO-8859-1 文字列をシングルバイトの ISO-8859-1 に変換する
  • idn_strerror() - Returns string describing the IDNA error code
  • idn_to_ascii() - Convert UTF-8 encoded domain name to ASCII



add a note add a note User Contributed Notes
idn_to_utf8
There are no user contributed notes for this page.

intl> <idn_to_ascii
Last updated: Fri, 30 Jan 2009
 
 
show source | credits | sitemap | contact | advertising | mirror sites