There are multibyte string functions in PHP to handle multibyte string (e.g:CJK script). For example, I want to count how many letters in a multi bytes string by using
Try converting it to unicode first:
unicode
print len(japanese.decode("utf-8"))
gives 7. You are working on the utf-8 encoded string, which indeed has 21 bytes.