Browse Source

Change gb18030 loop to be consistent with Big5 and EUC-KR

span
J. King 6 years ago
parent
commit
fb70543c0f
  1. 2
      lib/Encoding/GBCommon.php

2
lib/Encoding/GBCommon.php

@ -177,11 +177,11 @@ abstract class GBCommon implements StatelessEncoding {
$start = $this->posByte + 2; $start = $this->posByte + 2;
// go back bytes until a definite trail byte or start of string // go back bytes until a definite trail byte or start of string
while ($this->posByte > 0) { while ($this->posByte > 0) {
$b2 = ord(@$this->string[--$this->posByte]);
if ($b2 < 0x81 || $b2 == 0xFF) { if ($b2 < 0x81 || $b2 == 0xFF) {
$this->posByte++; $this->posByte++;
break; break;
} }
$b2 = ord(@$this->string[--$this->posByte]);
} }
// if the number of ambiguous bytes is odd, the character is a single-byte character, otherwise it is double-byte // if the number of ambiguous bytes is odd, the character is a single-byte character, otherwise it is double-byte
$this->posByte = $start - (($start - $this->posByte) % 2 ? 1 : 2); $this->posByte = $start - (($start - $this->posByte) % 2 ? 1 : 2);

Loading…
Cancel
Save