From fb70543c0f7a45cb5c289b37eec08201a0cd2e00 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Sat, 15 Sep 2018 14:02:17 -0400 Subject: [PATCH] Change gb18030 loop to be consistent with Big5 and EUC-KR --- lib/Encoding/GBCommon.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Encoding/GBCommon.php b/lib/Encoding/GBCommon.php index ccf7d98..6689a22 100644 --- a/lib/Encoding/GBCommon.php +++ b/lib/Encoding/GBCommon.php @@ -177,11 +177,11 @@ abstract class GBCommon implements StatelessEncoding { $start = $this->posByte + 2; // go back bytes until a definite trail byte or start of string while ($this->posByte > 0) { + $b2 = ord(@$this->string[--$this->posByte]); if ($b2 < 0x81 || $b2 == 0xFF) { $this->posByte++; 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 $this->posByte = $start - (($start - $this->posByte) % 2 ? 1 : 2);