Hi all,
I want to write some UTF-8 Chinese characters to file with following
php codes:
<code>
.......
$fp = fopen($filepath,'wb');
fwrite($fp,$utf8string,strlen($utf8string));
fclose($fp);
........
</code>
Problem happened on function "strlen". utf-8 string consists of
multibye characters. Every characters have more than one byte. But to
function "strlen", every character is just one byte.
Take Chinese character "我" for example, its utf-8 code is "0xE6
0x88 0x91“,obviously 3 bytes, but strlen return 1 byte. And then
function "fwrite" just write 1 byte to the file.
So I wonder if there are any way to get actural length of multibyte
string in PHP?
Thank you for suggestions!