How to check that a string contains only international letters and spaces in UTF8 in PHP?

In Python, I could convert it to Unicode and do a '(? U) ^ [\ w] + $' regular search, but PHP doesn't seem to understand international \ w, or does it?

+3
source share
3 answers

Although I have not tested myself looking at http://us3.php.net/manual/en/reference.pcre.pattern.syntax.php , it offers the following: '/ ^ [\ p {L}] + $ / u' will work - \ p {L} will match any unicode letter. In addition, you can write this without curly braces - '/ ^ [\ pL] + $ / u'.

+8
source

afaik PHP does not know utf8, which means that php itself will not be able to process it, except in different ways.

PHP , latin1, , , , mbstring.

http://se.php.net/mbstring

+1

UNICODE, , "" PHP6.

Until this word, you are advised NOT to use UNICODE in php because of the many security problems that may arise from it.

Many of the code is simply not aware of UNICODE and is therefore unsafe, and exploits can go through this in ways that are really unpleasant.

0
source

Source: https://habr.com/ru/post/1699494/


All Articles