简体   繁体   中英

Are functions like strip_tags() and trim() UTF-8 aware?

I'm wondering whether functions like strip_tags() and trim() UTF-8 aware?

I found this on the web, but I'm not sure about it:

strip_tags() : multi-byte UTF-8 characters contain no byte sequences that resemble less-than or greater-than symbols.

trim() : multi-byte UTF-8 characters contain no byte sequences that resemble white space.

If it's true, using those functions with an UTF-8 string could lead to a corrupted/illegible string.

Thank you.

I think the descriptions you quoted mean just the opposite. Because utf8 multi-byte characters DON'T contains whitespace, or lt/gt, or any other byte < 0x80, you can safely use those functions on utf8 strings. That's the beauty of utf8!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM