usr/bin/idn000075500000100720147207270300006627 0ustar00ELF>d,@@z@8 @@@@@@88@8@@@LfLf mm`m` mm`m`TT@T@DDPtd__@_@QtdRtdmm`m`@@/lib64/ld-linux-x86-64.so.2GNU GNUmG {&>@.3OF; ;<)fUa9q  N 6u5GtAgF<* zt 9 Y_M mt`t`t`libidn.so.11_ITM_deregisterTMCloneTable__gmon_start___Jv_RegisterClasses_ITM_registerTMCloneTabletld_strerrortld_check_4zstringprep_ucs4_to_utf8stringprep_utf8_nfkc_normalizeidna_to_unicode_8z4zstringprep_locale_to_utf8punycode_decodestringprep_strerroridna_to_ascii_4zstringprep_locale_charsetpunycode_encodestringprep_profilestringprep_utf8_to_ucs4stringprep_utf8_to_localepunycode_strerroridna_strerrorlibc.so.6__printf_chkexitsetlocalefopenoptindstrrchrdcgettextstrncpy__stack_chk_failputcharabortstdinprogram_invocation_nameisattyfeoffgetsstrlen__errno_location__fprintf_chkstdoutfputsmemcpyfclosemallocoptargstderroptoptgetopt_longfilenofwriteprogram_invocation_short_namebindtextdomainopterr__libc_start_mainferrorfree__progname__progname_fullLIBIDN_1.0GLIBC_2.3.4GLIBC_2.14GLIBC_2.4GLIBC_2.2.5 p/ +ti 6Bii Mui Wo`;t`;o`o`o`!o`#o`$o`9o`:o`=t`=t`<p` p`(p`0p`8p`@p`Hp` Pp` Xp` `p` hp` pp`xp`p`p`p`p`p`p`p`p`p`p`p`p`p`p`p` p`!q`"q`%q`&q`' q`((q`)0q`*8q`+@q`,Hq`.Pq`/Xq`0`q`1hq`2pq`4xq`5q`6q`7HHU] HtH5r] %t] @%r] h%j] h%b] h%Z] h%R] h%J] h%B] h%:] hp%2] h`%*] h P%"] h @%] h 0%] h % ] h %] h%\ h%\ h%\ h%\ h%\ h%\ h%\ h%\ h%\ hp%\ h`%\ hP%\ h@%\ h0%\ h %\ h%\ h%z\ h%r\ h %j\ h!%b\ h"%Z\ h#%R\ h$%J\ h%%B\ h&%:\ h'p%2\ h(`%*\ h)P%"\ h*@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A^A_H¾1LcH5H1~HXHH[]MH¾A\A]A^A_1XLkLcH5H12HXHMHMH[]A\A]A^A_1 fLsLkH5iLcH1L4$HMMHپH1'f.L{ LsH59LkLc1HL|$HL4$MMHپH1fLCH5Lc(L{ Ls1LkHLD$01LD$0HLd$L|$L4$MHپH1nLKLCH5Lk0Lc(1L{ LsHLL$8LD$0LL$8LD$0HLl$Ld$HL|$L4$H1IHH 1wfLS@LK8HCLCH5Lk0Lc(L{ LsLT$HLL$@HD$0LD$8HE1I8tIK<u@HhLE1dL%(LD$XE1I$ELXADMMOt.II t$DA0rLXMSLPMMOuHD$XdH3%(uHhfHLD$@LL$Ht7)D$P)L$`)T$p)$)$)$)$)$dH%(HD$1H$IHD$HD$ $ D$0HD$HD$dH3%(uHfSH51H!Hƿ1H51H <HHƿ1H( H5@1HIHH[f.AWAAVIAUIATL%X& UH-X& SL)1HHHtLLDAHH9uH[]A\A]A^A_ff.fHHNameprep/usr/share/localelibidnSimon Josefsson1.28GNU LibidnCharset `%s'. input errorinput[%lu] = U+%04x stringprep_profile: %soutput[%lu] = U+%04x punycode_encode: %smallocpunycode_decode: %sidna_to_ascii_4z: %stld[%lu] = U+%04x tld_check_4z: %sidna_to_unicode_8z4z: %sUsage: %s [OPTION]... [STRINGS]... Internationalized Domain Name (IDN) convert STRINGS, or standard input. Command line interface to the internationalized domain name library. All strings are expected to be encoded in the preferred charset used by your locale. Use `--debug' to find out what this charset is. You can override the charset used by setting environment variable CHARSET. To process a string that starts with `-', for example `-foo', use `--' to signal the end of parameters, as in `idn --quiet -a -- -foo'. Mandatory arguments to long options are mandatory for short options too. -h, --help Print help and exit -V, --version Print version and exit -s, --stringprep Prepare string according to nameprep profile -d, --punycode-decode Decode Punycode -e, --punycode-encode Encode Punycode -a, --idna-to-ascii Convert to ACE according to IDNA (default mode) -u, --idna-to-unicode Convert from ACE according to IDNA --allow-unassigned Toggle IDNA AllowUnassigned flag (default off) --usestd3asciirules Toggle IDNA UseSTD3ASCIIRules flag (default off) --no-tld Don't check string for TLD specific rules Only for --idna-to-ascii and --idna-to-unicode -n, --nfkc Normalize string according to Unicode v3.2 NFKC -p, --profile=STRING Use specified stringprep profile instead Valid stringprep profiles: `Nameprep', `iSCSI', `Nodeprep', `Resourceprep', `trace', `SASLprep' --debug Print debugging information --quiet Silent operation only one of -s, -e, -d, -a, -u or -n can be specifiedTry `%s --help' for more information. %s %s Copyright 2002-2013 Simon Josefsson. GNU Libidn is free software with ABSOLUTELY NO WARRANTY. For more information about these matters, see . Type each input string on a line by itself, terminated by a newline character. could not convert from %s to UTF-8could not convert from UTF-8 to UCS-4could not convert from UTF-8 to %scould not convert from UCS-4 to UTF-8idna_to_unicode_8z4z (TLD): %stld_check_4z (position %lu): %scould not do NFKC normalizationCopyright %s %d Simon Josefsson.%s %s %s %s full-helpversionstringpreppunycode-decodepunycode-encodeidna-to-asciiidna-to-unicodeallow-unassignedusestd3asciirulesno-tldhidden-nfkcprofile%s="%s" debugquietwhVsdeautnkp:%s: option unknown: %c%s %s: `--%s' (`-%c') option given more than once%s %s: `--%s' option given more than once%s %s: cannot dump options to stream %s: cannot open file for writing: %s -h, --help Print help and exit --full-help Print help, including hidden options, and exit -V, --version Print version and exit -s, --stringprep Prepare string according to nameprep profile -d, --punycode-decode Decode Punycode -e, --punycode-encode Encode Punycode -a, --idna-to-ascii Convert to ACE according to IDNA (default) -u, --idna-to-unicode Convert from ACE according to IDNA --allow-unassigned Toggle IDNA AllowUnassigned flag (default=off) --usestd3asciirules Toggle IDNA UseSTD3ASCIIRules flag (default=off) -t, --tld Check string for TLD specific rules Only for --idna-to-ascii and --idna-to-unicode (default=on) --no-tld Don't check string for TLD specific rules Only for --idna-to-ascii and --idna-to-unicode (default=off) -n, --nfkc Normalize string according to Unicode v3.2 NFKC -k, --hidden-nfkc Hidden parameter for backwards compatibility -p, --profile=STRING Use specified stringprep profile instead Valid stringprep profiles are `Nameprep', `iSCSI', `Nodeprep', `Resourceprep', `trace', and `SASLprep'. --debug Print debugging information (default=off) --quiet Silent operation (default=off)Usage: idn [OPTION]... [STRING]...tL$D\A NULL argv[0] was passed through an exec system call. /.libs/lt-%s (%s) %s (C)Written by %s. Written by %s and %s. Written by %s, %s, and %s. Report bugs to: %s bug-libidn@gnu.org%s home page: <%s> License GPLv3+: GNU GPL version 3 or later . This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by %s, %s, %s, and %s. Written by %s, %s, %s, %s, and %s. Written by %s, %s, %s, %s, %s, and %s. Written by %s, %s, %s, %s, %s, %s, and %s. Written by %s, %s, %s, %s, %s, %s, %s, and %s. Written by %s, %s, %s, %s, %s, %s, %s, %s, and %s. Written by %s, %s, %s, %s, %s, %s, %s, %s, %s, and others. http://www.gnu.org/software/libidn/General help using GNU software: @(xX;Hp  8 0`Ph@PpXx0@@`zRx t*zRx $pFJ w?;*3$"LDHBBB B(A0H8OC 8A0A(B BBBE ,0AAG $AA,DAAG m AAH L ADG0X AAJ  CAD L CAH O CAE \`!$txD@ D R F 4Ar4ArD +BPB B(A0A8 0A(B BBB$)< AY,\ ADD0 AAB 4qBKD c CBG hAGHL@BBB E(D0D8G 8A0A(B BBBJ ,"AN A $L oAG0N AA thphD{ A BBB B(D0D8G 8A0A(B BBBE  8A0A(B BBBB b 8G0A(B BBBV ^ 8G0A(M BBBO b 8P0A(B BBBU t Dp} A `G A A}D`eBEE E(H0H8M@l8A0A(B BBB4 -@-@ p@ G@m`m`o@@@ c p`h@ @  ox @oo @m`@@@@@@@@&@6@F@V@f@v@@@@@@@@@@@&@6@F@V@f@v@@@@@@@@@@@&@6@F@V@f@v@@R@hR@R@VR@sR@dR@eR@aR@uR@R@S@tS@S@nS@k#S@p4S@:S@(T@XT@T@T@(U@XU@U@U@V@`V@V@hW@(X@xX@X@Y@Z@R@PZ@R@idn.debug7zXZִF!t/?]?Eh=ڊ̓NAkADN[GVˈ+ݾp9I#.[M'.|zfb D@Q]bj`_|GӏfdPd,TU+ XN>lOS6A.Jfҽ1-M !{<9r۝C8TVY j6~xMJ9{慰 GB*רf}զ?m=YW'Y@CZG4xa8ؘ1e.d(QMOƲkQ*4z $eлВREAeW}֢I~~v3wz[gySGmtf55=v'9c}#7r^XD~>p9)Va%e)UGnU\Cuw&LW`of&AH>1@w&8Tu+_C玹>o @F@cNo @ |[ox @x pj @ t@h ~p@py@@42G@G G@G _@_`@`|m`mm`mm`mm`mo`oHp`pq`q t`t tty idn.c000064400000027312147577404330005505 0ustar00/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 2009 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Pierre A. Joye | | Gustavo Lopes | +----------------------------------------------------------------------+ */ /* $Id$ */ /* {{{ includes */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include "ext/standard/php_string.h" #include "intl_error.h" #include "intl_convert.h" /* }}} */ #ifdef UIDNA_INFO_INITIALIZER #define HAVE_46_API 1 /* has UTS#46 API (introduced in ICU 4.6) */ #endif enum { INTL_IDN_VARIANT_2003 = 0, INTL_IDN_VARIANT_UTS46 }; /* {{{ grapheme_register_constants * Register API constants */ void idn_register_constants( INIT_FUNC_ARGS ) { /* OPTIONS */ /* Option to prohibit processing of unassigned codepoints in the input and do not check if the input conforms to STD-3 ASCII rules. */ REGISTER_LONG_CONSTANT("IDNA_DEFAULT", UIDNA_DEFAULT, CONST_CS | CONST_PERSISTENT); /* Option to allow processing of unassigned codepoints in the input */ REGISTER_LONG_CONSTANT("IDNA_ALLOW_UNASSIGNED", UIDNA_ALLOW_UNASSIGNED, CONST_CS | CONST_PERSISTENT); /* Option to check if input conforms to STD-3 ASCII rules */ REGISTER_LONG_CONSTANT("IDNA_USE_STD3_RULES", UIDNA_USE_STD3_RULES, CONST_CS | CONST_PERSISTENT); #ifdef HAVE_46_API /* Option to check for whether the input conforms to the BiDi rules. * Ignored by the IDNA2003 implementation. (IDNA2003 always performs a BiDi check.) */ REGISTER_LONG_CONSTANT("IDNA_CHECK_BIDI", UIDNA_CHECK_BIDI, CONST_CS | CONST_PERSISTENT); /* Option to check for whether the input conforms to the CONTEXTJ rules. * Ignored by the IDNA2003 implementation. (The CONTEXTJ check is new in IDNA2008.) */ REGISTER_LONG_CONSTANT("IDNA_CHECK_CONTEXTJ", UIDNA_CHECK_CONTEXTJ, CONST_CS | CONST_PERSISTENT); /* Option for nontransitional processing in ToASCII(). * By default, ToASCII() uses transitional processing. * Ignored by the IDNA2003 implementation. */ REGISTER_LONG_CONSTANT("IDNA_NONTRANSITIONAL_TO_ASCII", UIDNA_NONTRANSITIONAL_TO_ASCII, CONST_CS | CONST_PERSISTENT); /* Option for nontransitional processing in ToUnicode(). * By default, ToUnicode() uses transitional processing. * Ignored by the IDNA2003 implementation. */ REGISTER_LONG_CONSTANT("IDNA_NONTRANSITIONAL_TO_UNICODE", UIDNA_NONTRANSITIONAL_TO_UNICODE, CONST_CS | CONST_PERSISTENT); #endif /* VARIANTS */ REGISTER_LONG_CONSTANT("INTL_IDNA_VARIANT_2003", INTL_IDN_VARIANT_2003, CONST_CS | CONST_PERSISTENT); #ifdef HAVE_46_API REGISTER_LONG_CONSTANT("INTL_IDNA_VARIANT_UTS46", INTL_IDN_VARIANT_UTS46, CONST_CS | CONST_PERSISTENT); #endif #ifdef HAVE_46_API /* PINFO ERROR CODES */ REGISTER_LONG_CONSTANT("IDNA_ERROR_EMPTY_LABEL", UIDNA_ERROR_EMPTY_LABEL, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IDNA_ERROR_LABEL_TOO_LONG", UIDNA_ERROR_LABEL_TOO_LONG, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IDNA_ERROR_DOMAIN_NAME_TOO_LONG", UIDNA_ERROR_DOMAIN_NAME_TOO_LONG, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IDNA_ERROR_LEADING_HYPHEN", UIDNA_ERROR_LEADING_HYPHEN, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IDNA_ERROR_TRAILING_HYPHEN", UIDNA_ERROR_TRAILING_HYPHEN, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IDNA_ERROR_HYPHEN_3_4", UIDNA_ERROR_HYPHEN_3_4, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IDNA_ERROR_LEADING_COMBINING_MARK", UIDNA_ERROR_LEADING_COMBINING_MARK, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IDNA_ERROR_DISALLOWED", UIDNA_ERROR_DISALLOWED, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IDNA_ERROR_PUNYCODE", UIDNA_ERROR_PUNYCODE, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IDNA_ERROR_LABEL_HAS_DOT", UIDNA_ERROR_LABEL_HAS_DOT, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IDNA_ERROR_INVALID_ACE_LABEL", UIDNA_ERROR_INVALID_ACE_LABEL, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IDNA_ERROR_BIDI", UIDNA_ERROR_BIDI, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IDNA_ERROR_CONTEXTJ", UIDNA_ERROR_CONTEXTJ, CONST_CS | CONST_PERSISTENT); #endif } /* }}} */ enum { INTL_IDN_TO_ASCII = 0, INTL_IDN_TO_UTF8 }; /* like INTL_CHECK_STATUS, but as a function and varying the name of the func */ static int php_intl_idn_check_status(UErrorCode err, const char *msg, int mode TSRMLS_DC) { intl_error_set_code(NULL, err TSRMLS_CC); if (U_FAILURE(err)) { char *buff; spprintf(&buff, 0, "%s: %s", mode == INTL_IDN_TO_ASCII ? "idn_to_ascii" : "idn_to_utf8", msg); intl_error_set_custom_msg(NULL, buff, 1 TSRMLS_CC); efree(buff); return FAILURE; } return SUCCESS; } static inline void php_intl_bad_args(const char *msg, int mode TSRMLS_DC) { php_intl_idn_check_status(U_ILLEGAL_ARGUMENT_ERROR, msg, mode TSRMLS_CC); } #ifdef HAVE_46_API static void php_intl_idn_to_46(INTERNAL_FUNCTION_PARAMETERS, const char *domain, int domain_len, uint32_t option, int mode, zval *idna_info) { UErrorCode status = U_ZERO_ERROR; UIDNA *uts46; int32_t len; int32_t buffer_capac = 255; /* no domain name may exceed this */ char *buffer = emalloc(buffer_capac); UIDNAInfo info = UIDNA_INFO_INITIALIZER; int buffer_used = 0; uts46 = uidna_openUTS46(option, &status); if (php_intl_idn_check_status(status, "failed to open UIDNA instance", mode TSRMLS_CC) == FAILURE) { efree(buffer); RETURN_FALSE; } if (mode == INTL_IDN_TO_ASCII) { len = uidna_nameToASCII_UTF8(uts46, domain, (int32_t)domain_len, buffer, buffer_capac, &info, &status); } else { len = uidna_nameToUnicodeUTF8(uts46, domain, (int32_t)domain_len, buffer, buffer_capac, &info, &status); } if (len >= 255 || php_intl_idn_check_status(status, "failed to convert name", mode TSRMLS_CC) == FAILURE) { uidna_close(uts46); efree(buffer); RETURN_FALSE; } buffer[len] = '\0'; if (info.errors == 0) { RETVAL_STRINGL(buffer, len, 0); buffer_used = 1; } else { RETVAL_FALSE; } if (idna_info) { if (buffer_used) { /* used in return_value then */ zval_addref_p(return_value); add_assoc_zval_ex(idna_info, "result", sizeof("result"), return_value); } else { zval *zv; ALLOC_INIT_ZVAL(zv); ZVAL_STRINGL(zv, buffer, len, 0); buffer_used = 1; add_assoc_zval_ex(idna_info, "result", sizeof("result"), zv); } add_assoc_bool_ex(idna_info, "isTransitionalDifferent", sizeof("isTransitionalDifferent"), info.isTransitionalDifferent); add_assoc_long_ex(idna_info, "errors", sizeof("errors"), (long)info.errors); } if (!buffer_used) { efree(buffer); } uidna_close(uts46); } #endif static void php_intl_idn_to(INTERNAL_FUNCTION_PARAMETERS, const char *domain, int domain_len, uint32_t option, int mode) { UChar* ustring = NULL; int ustring_len = 0; UErrorCode status; char *converted_utf8; int32_t converted_utf8_len; UChar converted[MAXPATHLEN]; int32_t converted_ret_len; /* convert the string to UTF-16. */ status = U_ZERO_ERROR; intl_convert_utf8_to_utf16(&ustring, &ustring_len, domain, domain_len, &status); if (U_FAILURE(status)) { intl_error_set_code(NULL, status TSRMLS_CC); /* Set error messages. */ intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 TSRMLS_CC ); if (ustring) { efree(ustring); } RETURN_FALSE; } else { UParseError parse_error; status = U_ZERO_ERROR; if (mode == INTL_IDN_TO_ASCII) { converted_ret_len = uidna_IDNToASCII(ustring, ustring_len, converted, MAXPATHLEN, (int32_t)option, &parse_error, &status); } else { converted_ret_len = uidna_IDNToUnicode(ustring, ustring_len, converted, MAXPATHLEN, (int32_t)option, &parse_error, &status); } efree(ustring); if (U_FAILURE(status)) { intl_error_set( NULL, status, "idn_to_ascii: cannot convert to ASCII", 0 TSRMLS_CC ); RETURN_FALSE; } status = U_ZERO_ERROR; intl_convert_utf16_to_utf8(&converted_utf8, &converted_utf8_len, converted, converted_ret_len, &status); if (U_FAILURE(status)) { /* Set global error code. */ intl_error_set_code(NULL, status TSRMLS_CC); /* Set error messages. */ intl_error_set_custom_msg( NULL, "Error converting output string to UTF-8", 0 TSRMLS_CC ); efree(converted_utf8); RETURN_FALSE; } } /* return the allocated string, not a duplicate */ RETURN_STRINGL(((char *)converted_utf8), converted_utf8_len, 0); } static void php_intl_idn_handoff(INTERNAL_FUNCTION_PARAMETERS, int mode) { char *domain; int domain_len; long option = 0, variant = INTL_IDN_VARIANT_2003; zval *idna_info = NULL; intl_error_reset(NULL TSRMLS_CC); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|llz", &domain, &domain_len, &option, &variant, &idna_info) == FAILURE) { php_intl_bad_args("bad arguments", mode TSRMLS_CC); RETURN_NULL(); /* don't set FALSE because that's not the way it was before... */ } #ifdef HAVE_46_API if (variant != INTL_IDN_VARIANT_2003 && variant != INTL_IDN_VARIANT_UTS46) { php_intl_bad_args("invalid variant, must be one of {" "INTL_IDNA_VARIANT_2003, INTL_IDNA_VARIANT_UTS46}", mode TSRMLS_CC); RETURN_FALSE; } #else if (variant != INTL_IDN_VARIANT_2003) { php_intl_bad_args("invalid variant, PHP was compiled against " "an old version of ICU and only supports INTL_IDN_VARIANT_2003", mode TSRMLS_CC); RETURN_FALSE; } #endif if (domain_len < 1) { php_intl_bad_args("empty domain name", mode TSRMLS_CC); RETURN_FALSE; } if (domain_len > INT32_MAX - 1) { php_intl_bad_args("domain name too large", mode TSRMLS_CC); RETURN_FALSE; } /* don't check options; it wasn't checked before */ if (idna_info != NULL) { if (variant == INTL_IDN_VARIANT_2003) { php_error_docref0(NULL TSRMLS_CC, E_NOTICE, "4 arguments were provided, but INTL_IDNA_VARIANT_2003 only " "takes 3 - extra argument ignored"); } else { zval_dtor(idna_info); array_init(idna_info); } } if (variant == INTL_IDN_VARIANT_2003) { php_intl_idn_to(INTERNAL_FUNCTION_PARAM_PASSTHRU, domain, domain_len, (uint32_t)option, mode); } #ifdef HAVE_46_API else { php_intl_idn_to_46(INTERNAL_FUNCTION_PARAM_PASSTHRU, domain, domain_len, (uint32_t)option, mode, idna_info); } #endif } /* {{{ proto int idn_to_ascii(string domain[, int options[, int variant[, array &idna_info]]]) Converts an Unicode domain to ASCII representation, as defined in the IDNA RFC */ PHP_FUNCTION(idn_to_ascii) { php_intl_idn_handoff(INTERNAL_FUNCTION_PARAM_PASSTHRU, INTL_IDN_TO_ASCII); } /* }}} */ /* {{{ proto int idn_to_utf8(string domain[, int options[, int variant[, array &idna_info]]]) Converts an ASCII representation of the domain to Unicode (UTF-8), as defined in the IDNA RFC */ PHP_FUNCTION(idn_to_utf8) { php_intl_idn_handoff(INTERNAL_FUNCTION_PARAM_PASSTHRU, INTL_IDN_TO_UTF8); } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ idn.h000064400000002474147577404330005514 0ustar00/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 2009 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Pierre A. Joye | +----------------------------------------------------------------------+ */ /* $Id$ s*/ #ifndef IDN_IDN_H #define IDN_IDN_H #include PHP_FUNCTION(idn_to_ascii); PHP_FUNCTION(idn_to_utf8); void idn_register_constants(INIT_FUNC_ARGS); #endif /* IDN_IDN_H */