GraphQL\Utils::charCodeAt PHP Method

charCodeAt() public static method

Returns UTF-8 char code at given $positing of the $string
public static charCodeAt ( $string, $position ) : mixed
$string
$position
return mixed
    public static function charCodeAt($string, $position)
    {
        $char = mb_substr($string, $position, 1, 'UTF-8');
        return self::ord($char);
    }

Usage Example

Example #1
0
 /**
  * Reads a comment token from the source file.
  *
  * #[\u0009\u0020-\uFFFF]*
  *
  * @param $start
  * @param $line
  * @param $col
  * @param Token $prev
  * @return Token
  */
 private function readComment($start, $line, $col, Token $prev)
 {
     $body = $this->source->body;
     $position = $start;
     do {
         $code = Utils::charCodeAt($body, ++$position);
     } while ($code !== null && ($code > 0x1f || $code === 0x9));
     return new Token(Token::COMMENT, $start, $position, $line, $col, $prev, mb_substr($body, $start + 1, $position - $start + 1, 'UTF-8'));
 }
All Usage Examples Of GraphQL\Utils::charCodeAt