posChar++; while(($b = @$this->string[$this->posByte++]) !== "") { $b = ord($b); if ($first === 0) { if ($b < 0x80) { return $b; } elseif ($b === 0x80) { return 0x20AC; } elseif ($b > 0x80 && $b < 0xFF) { $first = $b; } else { return self::err($this->errMode, [$this->posChar - 1, $this->posByte - 1]); } } elseif ($second === 0) { if ($b > 0x29 && $b < 0x40) { $second = $b; } else { if (($b > 0x39 && $b < 0x7F) || ($b > 0x7F && $b < 0xFF)) { $offset = ($b < 0x7F) ? 0x40 : 0x41; $pointer = ($first - 0x81) * 190 + ($b - $offset); return self::TABLE_GBK[$pointer]; } elseif ($b < 0x80) { return self::err($this->errMode, [$this->posChar - 1, --$this->posByte]); } else { return self::err($this->errMode, [$this->posChar - 1, $this->posByte - 1]); } } } elseif ($third === 0) { if ($b > 0x80 && $b < 0xFF) { $third = $b; } else { $this->posByte -= 2; return self::err($this->errMode, [$this->posChar - 1, $this->posByte - 1]); } } else { if ($b > 0x29 && $b < 0x40) { // look up code point $pointer = (($first - 0x81) * (10 * 126 * 10)) + (($second - 0x30) * (10 * 126)) + (($third - 0x81) * 10) + $b - 0x30; if ($pointer === 7457) { return 0xE7C7; } for ($a = 1; $a < sizeof(self::TABLE_RANGES); $a++) { if ($pointer < self::TABLE_RANGES[$a]) { $offset = self::TABLE_RANGES[$a - 1]; $codePointOffset = self::TABLE_OFFSETS[$a - 1]; break; } } if (isset($codePointOffset)) { return $codePointOffset + $pointer - $offset; } else { return self::err($this->errMode, [$this->posChar - 1, $this->posByte - 1]); } } else { $this->posByte -= 3; return self::err($this->errMode, [$this->posChar - 1, $this->posByte - 1]); } } } if (($first + $second + $third) == 0) { // clean EOF return false; } else { // dirty EOF return self::err($this->errMode, [--$this->posChar, --$this->posByte]); } } /** Returns the encoding of $codePoint as a byte string * * If $codePoint is less than 0 or greater than 1114111, an exception is thrown * * If $fatal is true, an exception will be thrown if the code point cannot be encoded into a character; otherwise HTML character references will be substituted. When encoding to UTF-8, all Unicode characters can be encoded, so the argument is ignored */ public static function encode(int $codePoint, bool $fatal = true): string { // stub } /** Advance $distance characters through the string * * If $distance is negative, the operation will be performed in reverse * * If the end (or beginning) of the string was reached before the end of the operation, the remaining number of requested characters is returned */ public function seek(int $distance): int { // stub } }