if ($b1 <0x40||$b1 ==0x7F||$this->posByte === $this->errMark || $this->posByte == 0) { // these bytes never appear in sequences, a byte coming after an error is necessarily its own character, and the first byte is necessarily the start of a sequence
if ($b1 <0x40||$b1 ==0x7F||$this->posByte === $this->errMark || $this->posByte == 0) { // these bytes never appear in sequences, a byte coming after an error is necessarily its own character, and the first byte is necessarily the start of a sequence
// the byte is a character
// the byte is a character
continue;
continue;
}
}
// go back a second byte
// go back a second byte
$b2 = ord(@$this->string[--$this->posByte]);
$b2 = ord($this->string[--$this->posByte] ?? "");
if ($b2 <0x80){//thesebytesneverappearintheleadofasequence
if ($b2 <0x80){//thesebytesneverappearintheleadofasequence
if ($b1 <0x41||$this->posByte === $this->errMark || $this->posByte == 0) { // these bytes never appear in sequences, a byte coming after an error is necessarily its own character, and the first byte is necessarily the start of a sequence
if ($b1 <0x41||$this->posByte === $this->errMark || $this->posByte == 0) { // these bytes never appear in sequences, a byte coming after an error is necessarily its own character, and the first byte is necessarily the start of a sequence
// the byte is a character
// the byte is a character
continue;
continue;
}
}
// go back a second byte
// go back a second byte
$b2 = ord(@$this->string[--$this->posByte]);
$b2 = ord($this->string[--$this->posByte] ?? "");
if ($b2 <0x80){//thesebytesneverappearintheleadofasequence
if ($b2 <0x80){//thesebytesneverappearintheleadofasequence
if ($b1 <0x40||$b1> 0xFC || $b1 === 0x7F || $this->posByte === 0 || $this->posByte === $this->errMark) { // these bytes never appear in sequences, and the first byte is necessarily the start of a sequence
if ($b1 <0x40||$b1> 0xFC || $b1 === 0x7F || $this->posByte === 0 || $this->posByte === $this->errMark) { // these bytes never appear in sequences, and the first byte is necessarily the start of a sequence
// the byte is a character
// the byte is a character
continue;
continue;
}
}
// go back a second byte
// go back a second byte
$b2 = ord(@$this->string[--$this->posByte]);
$b2 = ord($this->string[--$this->posByte] ?? "");
if ($b2 <0x81||$b2> 0xFC || ($b2 >= 0xA0 && $b2 <= 0xDF)) { // these bytes never appear in the lead of a sequence
if ($b2 <0x81||$b2> 0xFC || ($b2 >= 0xA0 && $b2 <= 0xDF)) { // these bytes never appear in the lead of a sequence
/* This string contains an invalid character sequence sandwiched between two null characters */
/* This string contains an invalid character sequence sandwiched between two null characters */
protected $brokenChar = "00 FF 00";
protected $brokenChar = "00 FF 00";
/* This string conatins the ASCII characters "A" and "Z" followed by two arbitrary non-ASCII characters, followed by the two ASCII characters "0" and "9" */
protected $spanString = "41 5A D7AA A4F4 30 39";
public function provideCodePoints() {
public function provideCodePoints() {
return [
return [
@ -195,6 +197,20 @@ class TestBig5 extends \MensBeam\Intl\Test\CoderDecoderTest {
/* This string contains an invalid character sequence sandwiched between two null characters */
/* This string contains an invalid character sequence sandwiched between two null characters */
protected $brokenChar = "00 FF 00";
protected $brokenChar = "00 FF 00";
/* This string conatins the ASCII characters "A" and "Z" followed by two arbitrary non-ASCII characters, followed by the two ASCII characters "0" and "9" */
/* This string contains an invalid character sequence sandwiched between two null characters */
/* This string contains an invalid character sequence sandwiched between two null characters */
protected $brokenChar = "00 FF 00";
protected $brokenChar = "00 FF 00";
/* This string conatins the ASCII characters "A" and "Z" followed by two arbitrary non-ASCII characters, followed by the two ASCII characters "0" and "9" */
protected $spanString = "41 5A E2A9 A5C1 30 39";
public function provideCodePoints() {
public function provideCodePoints() {
return [
return [
@ -185,6 +187,20 @@ class TestEUCKR extends \MensBeam\Intl\Test\CoderDecoderTest {
/* This string contains an invalid character sequence sandwiched between two null characters */
/* This string contains an invalid character sequence sandwiched between two null characters */
protected $brokenChar = "00 FF 00";
protected $brokenChar = "00 FF 00";
/* This string conatins the ASCII characters "A" and "Z" followed by two arbitrary non-ASCII characters, followed by the two ASCII characters "0" and "9" */
/* This string contains an invalid character sequence sandwiched between two null characters */
/* This string contains an invalid character sequence sandwiched between two null characters */
protected $brokenChar = "00 FF 00";
protected $brokenChar = "00 FF 00";
/* This string conatins the ASCII characters "A" and "Z" followed by two arbitrary non-ASCII characters, followed by the two ASCII characters "0" and "9" */
/* This string contains an invalid character sequence sandwiched between two null characters */
/* This string contains an invalid character sequence sandwiched between two null characters */
protected $brokenChar = "00 FF 00";
protected $brokenChar = "00 FF 00";
/* This string conatins the ASCII characters "A" and "Z" followed by two arbitrary non-ASCII characters, followed by the two ASCII characters "0" and "9" */
protected $spanString = "41 5A D6 82E6 30 39";
public function provideCodePoints() {
public function provideCodePoints() {
return [
return [
@ -198,6 +200,20 @@ class TestShiftJIS extends \MensBeam\Intl\Test\CoderDecoderTest {
/* This string is supposed to contain an invalid character sequence sandwiched between two null characters; this is different for each single-byte encoding (and many do not have invalid characters) */
/* This string is supposed to contain an invalid character sequence sandwiched between two null characters; this is different for each single-byte encoding (and many do not have invalid characters) */
protected $brokenChar = "";
protected $brokenChar = "";
/* This string conatins the ASCII characters "A" and "Z" followed by two arbitrary non-ASCII characters, followed by the two ASCII characters "0" and "9" */
protected $spanString = "41 5A 80 FF 30 39";
/**
/**
* @dataProvider provideCodePoints
* @dataProvider provideCodePoints
@ -234,6 +236,24 @@ class TestSingleByte extends \MensBeam\Intl\Test\CoderDecoderTest {
/* This string contains an invalid character sequence sandwiched between two null characters */
/* This string contains an invalid character sequence sandwiched between two null characters */
protected $brokenChar = "0000 DC00 0000";
protected $brokenChar = "0000 DC00 0000";
/* This string conatins the ASCII characters "A" and "Z" followed by two arbitrary non-ASCII characters, followed by the two ASCII characters "0" and "9" */
/* This string contains an invalid character sequence sandwiched between two null characters */
/* This string contains an invalid character sequence sandwiched between two null characters */
protected $brokenChar = "0000 00DC 0000";
protected $brokenChar = "0000 00DC 0000";
/* This string conatins the ASCII characters "A" and "Z" followed by two arbitrary non-ASCII characters, followed by the two ASCII characters "0" and "9" */
/* This string contains an invalid character sequence sandwiched between two null characters */
/* This string contains an invalid character sequence sandwiched between two null characters */
protected $brokenChar = "00 FF 00";
protected $brokenChar = "00 FF 00";
/* This string conatins the ASCII characters "A" and "Z" followed by two arbitrary non-ASCII characters, followed by the two ASCII characters "0" and "9" */
/* This string is supposed to contain an invalid character sequence sandwiched between two null characters, but x-user-defined has no invalid characters */
/* This string is supposed to contain an invalid character sequence sandwiched between two null characters, but x-user-defined has no invalid characters */
protected $brokenChar = "";
protected $brokenChar = "";
/* This string conatins the ASCII characters "A" and "Z" followed by two arbitrary non-ASCII characters, followed by the two ASCII characters "0" and "9" */
protected $spanString = "41 5A 80 FF 30 39";
public function provideCodePoints() {
public function provideCodePoints() {
return [
return [
@ -183,4 +185,18 @@ class TestXUserDefined extends \MensBeam\Intl\Test\CoderDecoderTest {