Here's my UTF-8 text file:
orange[t:주황색][*r:juhwangsaeg]
apple[t:사과][*r:sagwa]
I break it up into an array:
$word
: orange,apple
$trans
: 주황색,사과
$readable
: r:juhwangsaeg, sagwa
I only need to count the letters of each $word
, so for the first word "orange":
$len = iconv_strlen($word, "UTF-8"); //$word=orange
print "word=$word,len=$len"; // $word=orange,$len=7
The problem is that $len
always gives me 7 instead of 6 when it counts "orange", but it has no problem reading the next word (word=apple, len=5) or any other words in my array.
I've tried several different ways to overcome this problem using mb_strlen
etc, but I still can't figure out why it keeps counting an extra character when I read the first word.