• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/punycode.php
  • Класс: CBXPunycode
  • Вызов: CBXPunycode::Decode
public function Decode($domainName)
{
	$this->ClearErrors();

	$domainName = mb_strtolower(trim($domainName));

	$scheme = "";
	$schemePosition = mb_strpos($domainName, "://");
	if ($schemePosition !== false)
	{
		$scheme = mb_substr($domainName, 0, $schemePosition);
		$domainName = mb_substr($domainName, $schemePosition + 3);
	}

	$port = "";
	if (preg_match("/^(.+):([0-9]+)$/", $domainName, $portMatch))
	{
		$port = $portMatch[2];
		$domainName = $portMatch[1];
	}

	if ($this->encoding != "utf-8")
		$domainName = BitrixMainTextEncoding::convertEncoding($domainName, $this->encoding, "utf-8");

	$domainNameUcs4 = $this->Utf8ToUcs4($domainName);
	if (empty($domainNameUcs4))
		return "";

	$arDomainNameUcs4 = $this->ExplodeDomainName($domainNameUcs4);

	foreach ($arDomainNameUcs4 as $key => $value)
	{
		$checked = array_slice($value, 0, self::$punycodePrefixLength);
		if (self::$punycodePrefixUcs4 != $checked)
			continue;

		$arDomainNameUcs4[$key] = $this->DoDecodeUcs4($value);
	}

	$domainNameUcs4 = $this->ImplodeDomainName($arDomainNameUcs4);
	$domainName = $this->Ucs4ToUtf8($domainNameUcs4);

	if ($this->encoding != "utf-8")
		$domainName = BitrixMainTextEncoding::convertEncoding($domainName, "utf-8", $this->encoding);

	if (!empty($scheme))
		$domainName = $scheme."://".$domainName;

	if ($port !== "")
		$domainName = $domainName.":".$port;

	return $domainName;
}