--- lbbs/utils/lib/str_process.inc.php 2025/05/03 14:52:26 1.1 +++ lbbs/utils/lib/str_process.inc.php 2025/07/02 04:17:33 1.3 @@ -1,5 +1,5 @@ 127 && $v1 <= 255) // GBK chinese character + if ($v1 & 0b10000000) //head of multi-byte character { - $i++; - $c .= $str[$i]; + $v2 = ($v1 & 0b01110000) << 1; + while ($v2 & 0b10000000) + { + $i++; + $c .= $str[$i]; + $v2 = ($v2 & 0b01111111) << 1; + } $ret += 2; } @@ -65,14 +70,19 @@ function split_line(string $str, string continue; } - // Process GBK Chinese characters + // Process UTF-8 Chinese characters $v1 = ord($c); - if ($v1 > 127 && $v1 <= 255) // GBK chinese character + if ($v1 & 0b10000000) //head of multi-byte character { - $i++; - $c .= $str[$i]; + $v2 = ($v1 & 0b01110000) << 1; + while ($v2 & 0b10000000) + { + $i++; + $c .= $str[$i]; + $v2 = ($v2 & 0b01111111) << 1; + } - // Each GBK CJK character should use two character length for display + // Each UTF-8 CJK character should use two character length for display if ($line_len + 2 > $width) { if ($lines_count + 1 >= $lines_limit)