--- fenglin/lib/str_process.inc.php 2025/07/02 02:00:57 1.20 +++ fenglin/lib/str_process.inc.php 2025/10/18 14:15:35 1.21 @@ -10,14 +10,14 @@ function str_length(string $str) : int // Process UTF-8 Chinese characters $v1 = ord($c); - if ($v1 & 0b10000000) //head of multi-byte character + if ($v1 & 0x80) //head of multi-byte character { - $v2 = ($v1 & 0b01110000) << 1; - while ($v2 & 0b10000000) + $v2 = ($v1 & 0x70) << 1; + while ($v2 & 0x80) { $i++; $c .= $str[$i]; - $v2 = ($v2 & 0b01111111) << 1; + $v2 = ($v2 & 0x7f) << 1; } $ret += 2; @@ -72,14 +72,14 @@ function split_line(string $str, string // Process UTF-8 Chinese characters $v1 = ord($c); - if ($v1 & 0b10000000) //head of multi-byte character + if ($v1 & 0x80) //head of multi-byte character { - $v2 = ($v1 & 0b01110000) << 1; - while ($v2 & 0b10000000) + $v2 = ($v1 & 0x70) << 1; + while ($v2 & 0x80) { $i++; $c .= $str[$i]; - $v2 = ($v2 & 0b01111111) << 1; + $v2 = ($v2 & 0x7f) << 1; } // Each UTF-8 CJK character should use two character length for display