It is a function of PHP to determine whether the string encoding is utf8. oyksoft. compost49Returnstrueif $ stringisvalidUTF-8andfalseotherwise.functionis_utf8 ($ word) {if (preg_match (^ ([. chr (1, 228 ). -PHP function for determining whether the string encoding is utf8
Http://it.oyksoft.com/post/49/
// Returns true if $ string is valid UTF-8 and false otherwise. function is_utf8 ($ word) {if (preg_match ("/^ ([". chr (1, 228 ). "-". chr (1, 233 ). "] {1 }[". chr (1, 128 ). "-". chr (1, 191 ). "] {1 }[". chr (1, 128 ). "-". chr (1, 191 ). "] {1}) {1}/", $ word) = true | preg_match ("/([". chr (1, 228 ). "-". chr (1, 233 ). "] {1 }[". chr (1, 128 ). "-". chr (1, 191 ). "] {1 }[". chr (1, 128 ). "-". chr (1, 191 ). "] {1}) {1} $/", $ word) = true | preg_match ("/([". chr (1, 228 ). "-". chr (1, 233 ). "] {1 }[". chr (1, 128 ). "-". chr (1, 191 ). "] {1 }[". chr (1, 128 ). "-". chr (1, 191 ). "] {1}) {2,}/", $ word) = true) {return true;} else {return false ;}// function is_utf8