Translate input char to an input symbol of state machine

@param  string $char
@return integer
777346
private function _translateInput($char)
    {
        if        (strpos(self::QUERY_WHITE_SPACE_CHARS,    $char) !== false) { return self::IN_WHITE_SPACE;
        } else if (strpos(self::QUERY_SYNT_CHARS,           $char) !== false) { return self::IN_SYNT_CHAR;
        } else if (strpos(self::QUERY_MUTABLE_CHARS,        $char) !== false) { return self::IN_MUTABLE_CHAR;
        } else if (strpos(self::QUERY_LEXEMEMODIFIER_CHARS, $char) !== false) { return self::IN_LEXEME_MODIFIER;
        } else if (strpos(self::QUERY_ASCIIDIGITS_CHARS,    $char) !== false) { return self::IN_ASCII_DIGIT;
        } else if ($char === '"' ) { return self::IN_QUOTE;
        } else if ($char === '.' ) { return self::IN_DECIMAL_POINT;
        } else if ($char === '\\') { return self::IN_ESCAPE_CHAR;
        } else                                                                { return self::IN_CHAR;
        }
    }
752353
protected function charsToCodepointsWithSurrogates(array $chars)
	{
		$codepoints = [];
		foreach ($chars as $char)
		{
			$cp = $this->cp($char);
			if ($cp < 0x10000)
			{
				$codepoints[] = $cp;
			}
			else
			{
				$codepoints[] = 0xD7C0 + ($cp >> 10);
				$codepoints[] = 0xDC00 + ($cp & 0x3FF);
			}
		}

		return $codepoints;
	}
424593
function incChar(char, base = 10) {
  let val = charToVal(char);
  if (val < 0) throw new Error('in incChar, invalid character');
  val = (val + 1) % base;
  return consts.alphabet[val];
}
325412
public static function char2Unicode($char)
    {
        switch (strlen($char)) {
            case 1 :
                return ord($char);
            case 2 :
                return (ord($char{1}) & 63) |
                    ((ord($char{0}) & 31) << 6);
            case 3 :
                return (ord($char{2}) & 63) |
                    ((ord($char{1}) & 63) << 6) |
                    ((ord($char{0}) & 15) << 12);
            case 4 :
                return (ord($char{3}) & 63) |
                    ((ord($char{2}) & 63) << 6) |
                    ((ord($char{1}) & 63) << 12) |
                    ((ord($char{0}) & 7) << 18);
            default :
                trigger_error('Character is not UTF-8!', E_USER_WARNING);
                return false;
        }
    }
923890
public static char getChar(String symbol)
    {
        CharInfo info = (CharInfo) fSymbolMap.get(symbol);
        return (info != null) ? (char) info.fCode : '\0';
    }
1344191
private static function utf8chr($c)
    {
        if (0x80 > $c %= 0x200000) {
            return chr($c);
        }
        if (0x800 > $c) {
            return chr(0xC0 | $c >> 6).chr(0x80 | $c & 0x3F);
        }
        if (0x10000 > $c) {
            return chr(0xE0 | $c >> 12).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F);
        }

        return chr(0xF0 | $c >> 18).chr(0x80 | $c >> 12 & 0x3F).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F);
    }
767287
public function reset(?string $char = null): string
    {
        $this->initialize();
        return
            $this->sectionSeparator($char);
    }
375204
public function map(string $chars): string
    {
        //无目标语言时，返回自身
        if (self::$__i18n) {
            //自动加载
            if (!isset(self::$data[self::$__i18n][$this->__name])) {
                if (!isset(self::$data[self::$__i18n])) {
                    self::$data[self::$__i18n] = [];
                }
                self::$data[self::$__i18n][$this->__name] = call_user_func_array(self::$autoload, [$this->__name, self::$__i18n]) ?: [];
            }

            //是否存在目标字符
            if (isset(self::$data[self::$__i18n][$this->__name][$chars])) {
                $chars = self::$data[self::$__i18n][$this->__name][$chars];
            } elseif (is_callable($this->map)) {
                $chars = call_user_func($this->map, $chars);
            }
        }

        return $chars;
    }
282490
public function setUuid($chars = null){
        if (null === $chars && 32 != strlen($chars)) {
            $chars = md5 ( uniqid ( mt_rand (), true ) );
        } elseif ($chars !== null && 32 !== strlen($chars)){
            throw new \UnexpectedValueException('invalid characters for UUID generation provided');
        }
        $this->uuid =
            substr ( $chars, 0, 8 )  . '-' .
            substr ( $chars, 8, 4 )  . '-' .
            substr ( $chars, 12, 4 ) . '-' .
            substr ( $chars, 16, 4 ) . '-' .
            substr ( $chars, 20, 12 ) ;
        return $this;
    }
22751
protected function output($char)
    {
        $output = $this->getOutput();
        $output .= $char;
        $this->setOutput($output);
    }
346919
public static function mapTo( $charset )
    {
        $lowerCharset = strtolower( $charset );
        return isset( self::$mapping[$lowerCharset] ) ? self::$mapping[$lowerCharset] : $charset;
    }
713670
public function setDefaultCrossingChar(string $char): self
    {
        return $this->setCrossingChars($char, $char, $char, $char, $char, $char, $char, $char, $char);
    }
344428
public static function toUnicodeCodepoint($char)
    {
        $charCode = false;
        // 7bits, 1 char
        if ((ord($char[0]) & 0x80) == 0x00) {
            $charCode = ord($char[0]);
        } elseif ((ord($char[0]) & 0xe0) == 0xc0) { // 11 bits, 2 chars
            if ((ord($char[1]) & 0xc0) != 0x80) {
                return $charCode;
            }

            $charCode = (
                ((ord($char[0]) & 0x1f) << 6) +
                ((ord($char[1]) & 0x3f))
            );

            if ($charCode < 128) {
                throw new RuntimeException('Illegal UTF-8 input character: ' . $char);
            }
        } elseif ((ord($char[0]) & 0xf0) == 0xe0) { // 16 bits, 3 chars
            if ((ord($char[1]) & 0xc0) != 0x80 ||
                 (ord($char[2]) & 0xc0) != 0x80) {
                return $charCode;
            }
            $charCode = (
                ((ord($char[0]) & 0x0f) << 12) +
                ((ord($char[1]) & 0x3f) << 6) +
                ((ord($char[2]) & 0x3f))
            );

            if ($charCode < 2048) {
                throw new RuntimeException('Illegal UTF-8 input character: ' . $char);
            }
        } elseif ((ord($char[0]) & 0xf8) == 0xf0) { // 21 bits, 4 chars
            if ((ord($char[1]) & 0xc0) != 0x80 ||
                 (ord($char[2]) & 0xc0) != 0x80 ||
                 (ord($char[3]) & 0xc0) != 0x80) {
                return $charCode;
            }

            $charCode = (
                ((ord($char[0]) & 0x07) << 18) +
                ((ord($char[1]) & 0x3f) << 12) +
                ((ord($char[2]) & 0x3f) << 6) +
                ((ord($char[3]) & 0x3f))
            );

            if ($charCode < 65536) {
                throw new RuntimeException('Illegal UTF-8 input character: ' . $char);
            }
        } elseif ((ord($char[0]) & 0xfc) == 0xf8) { // 26 bits, 5 chars
            if ((ord($char[1]) & 0xc0) != 0x80 ||
                 (ord($char[2]) & 0xc0) != 0x80 ||
                 (ord($char[3]) & 0xc0) != 0x80 ||
                 (ord($char[4]) & 0xc0) != 0x80) {
                return $charCode;
            }

            $charCode = (
                ((ord($char[0]) & 0x03) << 24) +
                ((ord($char[1]) & 0x3f) << 18) +
                ((ord($char[2]) & 0x3f) << 12) +
                ((ord($char[3]) & 0x3f) << 6) +
                ((ord($char[4]) & 0x3f))
            );

            if ($charCode < 2097152) {
                throw new RuntimeException('Illegal UTF-8 input character: ' . $char);
            }
        } elseif ((ord($char[0]) & 0xfe) == 0xfc) { // 31 bits, 6 chars
            if ((ord($char[1]) & 0xc0) != 0x80 ||
                 (ord($char[2]) & 0xc0) != 0x80 ||
                 (ord($char[3]) & 0xc0) != 0x80 ||
                 (ord($char[4]) & 0xc0) != 0x80 ||
                 (ord($char[5]) & 0xc0) != 0x80) {
                return $charCode;
            }

            $charCode = (
                ((ord($char[0]) & 0x01) << 30) +
                ((ord($char[1]) & 0x3f) << 24) +
                ((ord($char[2]) & 0x3f) << 18) +
                ((ord($char[3]) & 0x3f) << 12) +
                ((ord($char[4]) & 0x3f) << 6) +
                ((ord($char[5]) & 0x3f))
            );

            if ($charCode < 67108864) {
                throw new RuntimeException('Illegal UTF-8 input character: ' . $char);
            }
        }

        return $charCode;
    }
678093
private int getState(int currentState, char character)
    {
        int newCurrentState = transitionWithRoot(currentState, character);  // 先按success跳转
        while (newCurrentState == -1) // 跳转失败的话，按failure跳转
        {
            currentState = fail[currentState];
            newCurrentState = transitionWithRoot(currentState, character);
        }
        return newCurrentState;
    }
163200
public static function listForCharacter($char)
    {
        $file = self::getDataFolder() . '/' . $char;
        $data = strtolower(file_get_contents($file));
        return explode("\n", $data);
    }
353816
public function char($char = null)
    {
        $pos = $this->pos;
        if ( ! is_null($char)) {
            $pos = $char;
        }

        if ( ! isset($this->content[$pos])) {
            return '';
        }

        return $this->content[$pos];
    }
394472
protected function normalizeCharForKeyEvent($char) {
    if (!is_int($char) && !is_string($char)) {
      throw new DriverException("Unsupported key type, can only be integer or string");
    }

    if (is_string($char) && strlen($char) !== 1) {
      throw new DriverException("Key can only have ONE character");
    }

    $key = $char;
    if (is_int($char)) {
      $key = chr($char);
    }
    return $key;
  }