--- fenglin/lib/str_process.inc.php 2025/04/23 05:13:57 1.16 +++ fenglin/lib/str_process.inc.php 2025/10/30 11:19:14 1.22 @@ -1,5 +1,5 @@ = $lines_limit) @@ -73,15 +72,14 @@ function split_line(string $str, string // Process UTF-8 Chinese characters $v1 = ord($c); - if (($v1 & 0b10000000) == 0b10000000) //head of multi-byte character + if ($v1 & 0x80) //head of multi-byte character { - $v2 = ($v1 & 0b01111000) << 1; - while ($v2 & 0b10000000) + $v2 = ($v1 & 0x70) << 1; + while ($v2 & 0x80) { $i++; - $v3 = $str[$i]; - $c .= $v3; - $v2 = ($v2 & 0b01111111 ) << 1; + $c .= $str[$i]; + $v2 = ($v2 & 0x7f) << 1; } // Each UTF-8 CJK character should use two character length for display @@ -127,4 +125,3 @@ function split_line(string $str, string return $result; } -?>