decode() public method

public decode ( $input )
Exemplo n.º 1
0
 /**
  * Decode a Punycode domain name to its Unicode counterpart
  *
  * @param string $input Domain name in Punycode
  *
  * @return string Unicode domain name
  */
 public function decode($input)
 {
     if ($this->idnSupport === true) {
         return idn_to_utf8($input);
     }
     return self::$punycode->decode($input);
 }
Exemplo n.º 2
0
 public function punycode(Request $request, Texts $textsModel, functions $functions)
 {
     $Punycode = new Punycode();
     $method = $request->input('method');
     $source = $request->input('source');
     if ($method == '') {
         $method = 'to_puny';
     }
     if ($method == "to_puny") {
         $res = $Punycode->encode($source);
     } else {
         $res = $Punycode->decode($source);
     }
     $langLinks = $functions->giveLangLinks($request->url());
     $params = $textsModel->getLocaleOf('punicode');
     return view('indexuse', ['params' => $params, 'res' => $res, 'source' => $source, 'method' => $method, 'langLinks' => $langLinks]);
 }
Exemplo n.º 3
0
 /**
  * Validate Host data before insertion into a URL host component
  *
  * @param mixed $data the data to insert
  *
  * @return array
  *
  * @throws RuntimeException If the added is invalid
  */
 protected function validate($data)
 {
     $data = $this->validateSegment($data);
     if (!$data) {
         return $data;
     }
     $this->saveInternalEncoding();
     if (!$this->isValidHostLength($data)) {
         $this->restoreInternalEncoding();
         throw new RuntimeException('Invalid hostname, check its length');
     }
     if (!$this->isValidHostPattern($data)) {
         $this->restoreInternalEncoding();
         throw new RuntimeException('Invalid host label, check its content');
     }
     if (!$this->isValidHostLabels($data)) {
         $this->restoreInternalEncoding();
         throw new RuntimeException('Invalid host label counts, check its count');
     }
     $data = $this->sanitizeValue($data);
     $data = explode($this->delimiter, $this->punycode->decode(implode($this->delimiter, $data)));
     $this->restoreInternalEncoding();
     return $data;
 }