Hi all, I'd like to be able to check whether a UTF-8 string is valid.
I'm currently using
$value = mb_convert_encoding($original_value, "UTF-8");
if (mb_strlen($value) != mb_strlen($original_value)) {
// something wrong
}
Of course, it's possible that this may not work.
mb_convert_encoding produces no error or warning if it encounters an invalid UTF-8 sequence, nor does it replace it with the character specified by mb_substitute_character.
Mark