Browse Source

Note self-synchronizing encodings for later

span
J. King 4 years ago
parent
commit
7ec8f148ff
  1. 1
      lib/Encoding/GenericEncoding.php
  2. 2
      lib/Encoding/SingleByteEncoding.php
  3. 2
      lib/Encoding/UTF16.php
  4. 2
      lib/Encoding/UTF8.php

1
lib/Encoding/GenericEncoding.php

@ -15,6 +15,7 @@ trait GenericEncoding {
protected $dirtyEOF = 0;
protected $errMode = self::MODE_REPLACE;
protected $allowSurrogates = false;
protected $selfSynchronizing = false;
public $posErr = 0;

2
lib/Encoding/SingleByteEncoding.php

@ -9,6 +9,8 @@ namespace MensBeam\Intl\Encoding;
abstract class SingleByteEncoding implements StatelessEncoding {
use GenericEncoding;
protected $selfSynchronizing = true;
public function nextChar(): string {
// get the byte at the current position
$b = @$this->string[$this->posChar];

2
lib/Encoding/UTF16.php

@ -9,6 +9,8 @@ namespace MensBeam\Intl\Encoding;
abstract class UTF16 implements Encoding {
use GenericEncoding;
protected $selfSynchronizing = true;
public function nextCode() {
$lead_b = null;
$lead_s = null;

2
lib/Encoding/UTF8.php

@ -12,6 +12,8 @@ class UTF8 implements StatelessEncoding {
const NAME = "UTF-8";
const LABELS = ["unicode-1-1-utf-8", "utf-8", "utf8"];
protected $selfSynchronizing = true;
public function nextCode() {
// this function effectively implements https://encoding.spec.whatwg.org/#utf-8-decoder
// optimization for ASCII characters

Loading…
Cancel
Save