how to check if a string is utf8, any is_utf8() function?
gnosis.kv - May 27, 2008 - 15:10
Hi,
What's the proper way to check if a given string is utf8? then based on this checking, we will decide to run drupal_convert_to_utf8 to the string or not?
so, i want some code snip, like
<?php
if(!is_utf8($string)){
$string = drupal_convert_to_utf8($string);
}
?>but, i dont know how to do the is_utf8 function.
any advise?
thanks a lot in advance

...
See http://php.net/mb_check_encoding.
(Notes: 1. plain ascii too is valid utf-8. 2. I don't know what's the probability that a random string in a valid encoding which isn't utf-8 will be validated as such, but it's probably very very low; it's better to run is_utf8() on the whole data and not on individual strings.)
thanks very much..
thanks very much..