UTF-8 validation in PHP without using preg_match()

后端 未结 5 701
梦如初夏
梦如初夏 2021-01-01 01:43

I need to validate some user input that is encoded in UTF-8. Many have recommended using the following code:

preg_match(\'/\\A(
     [\\x09\\x0A\\x0D\\x20-\\         


        
5条回答
  •  心在旅途
    2021-01-01 02:15

    You should be able to use iconv to check for validity. Just try and convert it to UTF-16 and see if you get an error.

提交回复
热议问题