1

Is there anyway to identify if doublebyte characters exists within a string using preg_match or strpos?

I am receiving XML files with chinese language text mixed with English and would like to skip any files that contain the chinese text. The XML is utf-8 encoded.

1 Answer 1

6

You can do something like this:

if (mb_strlen($string, 'UTF-8') != strlen($string)) {
  // string contains multibyte characters
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.