It is UTF-8. For example, 情報 is 2 characters while ラリー ペイジ is 6 characters.
When I use mb_strlen(), it is 6 for 情報 and 19 for ラリー ペイジ
Steven
2010-01-04 10:26:41
For some reason i get undefined function for mb_strlen :S
Question Mark
2010-01-04 10:29:15
Question Mark, check that you have the mbstring extension installed and activated in PHP.
Emil Vikström
2010-01-04 10:33:06
Steven, try to specify which encoding the string is in as the second parameter to mb_strlen. Maybe it failed to detect your encoding automatically.
Emil Vikström
2010-01-04 10:35:28
+4
A:
Code
$a = "情報";
$b = "ラリーペイジ";
echo mb_strlen($a, 'UTF-8') . "\n";
echo mb_strlen($b, 'UTF-8') . "\n";
Result
2
6
Peter Lindqvist
2010-01-04 10:29:47
This will probably get undefined results on characters which have no equivalent in ISO-8859-1.
Emil Vikström
2010-01-04 10:33:47
A:
Even if the second argument of mb_strlen is said optional, it is actually needed, even if your internal encoding and your string's one are the same, for portability purposes.
mb_strlen('情報', 'UTF-8');
The same applies for most multi-byte functions, including mb_substr, for wich the utf8_decode option would not work at all.
Benoit Vidis
2010-01-04 10:36:08