Check unicode in PHP

前端 未结 6 559
予麋鹿
予麋鹿 2020-12-28 17:36

How can I check whether a character is a Unicode character or not with PHP?

6条回答
  •  情深已故
    2020-12-28 17:59

    Strings in PHP are bytestreams - not character streams. You can't actually have unicode strings in PHP; You need to encode your characters with some encoding. If you want to cover the entire unicode range, UTF-8 is the most obvious choice.

    If you want to get the codepoint of a utf-8 encoded bytestream, you can use this library: http://hsivonen.iki.fi/php-utf8/

    However, I wonder what exactly you need this for? Most likely, you can solve all your woes by simply using utf-8.

提交回复
热议问题