예제 #1
0
Variant f_idn_to_utf8(CStrRef domain, VRefParam errorcode /* = null */) {
  return php_intl_idn_to(domain, ref(errorcode), INTL_IDN_TO_UTF8);
}
예제 #2
0
Variant f_idn_to_ascii(CStrRef domain, VRefParam errorcode /* = null */) {
  return php_intl_idn_to(domain, ref(errorcode), INTL_IDN_TO_ASCII);
}
예제 #3
0
Variant f_idn_to_utf8(const String& domain, int64_t options /* = 0 */,
                      int64_t variant /* = 0 */,
                      VRefParam idna_info /* = null */) {
  return php_intl_idn_to(domain, options, (IdnVariant)variant, idna_info,
                         INTL_IDN_TO_UTF8);
}
예제 #4
0
Variant f_idn_to_ascii(CStrRef domain, int64_t options /* = 0 */, int64_t variant /* = 0 */, VRefParam idna_info /* = null */) {
  return php_intl_idn_to(domain, options, (IdnVariant)variant, idna_info, INTL_IDN_TO_ASCII);
}
예제 #5
0
파일: idn.c 프로젝트: Furgas/php-src
static void php_intl_idn_handoff(INTERNAL_FUNCTION_PARAMETERS, int mode)
{
	char *domain;
	size_t domain_len;
	zend_long option = 0,
		 variant = INTL_IDN_VARIANT_2003;
	zval *idna_info = NULL;

	intl_error_reset(NULL);

	if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|llz/",
			&domain, &domain_len, &option, &variant, &idna_info) == FAILURE) {
		php_intl_bad_args("bad arguments", mode);
		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);
		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);
		RETURN_FALSE;
	}
#endif

	if (domain_len < 1) {
		php_intl_bad_args("empty domain name", mode);
		RETURN_FALSE;
	}
	if (domain_len > INT32_MAX - 1) {
		php_intl_bad_args("domain name too large", mode);
		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, 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, (int32_t)domain_len, (uint32_t)option, mode);
	}
#ifdef HAVE_46_API
	else {
		php_intl_idn_to_46(INTERNAL_FUNCTION_PARAM_PASSTHRU, domain, (int32_t)domain_len,
				(uint32_t)option, mode, idna_info);
	}
#endif
}
예제 #6
0
Variant f_idn_to_unicode(CStrRef domain, int64 options /* = 0 */, int64 variant /* = 0 */, VRefParam idna_info /* = null */) {
  return php_intl_idn_to(domain, options, (IdnVariant)variant, idna_info, INTL_IDN_TO_UTF8);
}