芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/.trash/libraries.2/vendor/algo26-matthias/idna-convert/src/ToIdn.php
unicodeTransCoder = new TranscodeUnicode(); $this->punycodeEncoder = new ToPunycode($idnVersion); } /** * @param string $host * * @return string * @throws InvalidCharacterException * @throws Exception\AlreadyPunycodeException */ public function convert(string $host): string { if (strlen($host) === 0) { return $host; } if (strpos('/', $host) !== false || strpos(':', $host) !== false || strpos('?', $host) !== false || strpos('@', $host) !== false ) { throw new InvalidCharacterException('Neither email addresses nor URLs are allowed', 205); } // These three punctuation characters are treated like the dot $host = str_replace(['。', '.', '。'], '.', $host); // Operate per label $hostLabels = explode('.', $host); foreach ($hostLabels as $index => $label) { $asUcs4Array = $this->unicodeTransCoder->convert( $label, $this->unicodeTransCoder::FORMAT_UTF8, $this->unicodeTransCoder::FORMAT_UCS4_ARRAY ); $encoded = $this->punycodeEncoder->convert($asUcs4Array); if ($encoded) { $hostLabels[$index] = $encoded; } } return implode('.', $hostLabels); } }