Using the PHP Function mb_check_encoding
With the release of PHP 5.0, the mbstring extension introduced a new way to handle multibyte strings. As well as iconv, this has a number of functions that are used to determine whether a sequence of characters is valid for the given encoding scheme and others that perform search oriented operations on such string sequences.
One of these is the mb_check_encoding function. It accepts two parameters, the encoding and the string to check for. It returns either a list of all the matching characters or FALSE if the string is not valid for the given encoding. This is similar to the strlen() function that is used in conjunction with the iconv functions to get a list of all the characters in a string.
As you might imagine, it is very useful to be able to use this function to validate UTF-8 sequences of characters, as they do not necessarily behave as expected when they are converted from other encodings. For example, they might fail to be correctly translated by JSON, or they might not be valid if the string is being used as an input into a database.
Another interesting mb_check_encoding function is mb_stripos. This function takes the string to look for, the needle, and a haystack string to search for it in, and return the position of the first occurrence of the needle within the haystack string. This function works in a very different manner to standard case folding functions, such as strtolower and strtoupper, as it uses Unicode character properties rather than alphabetic ordering.