PHP removes illegal UTF-8 characters

Source: Internet
Author: User

//reject overly long 2 byte sequences, as well as characters above u+10000 and replace with?$some _string = Preg_replace ('/[x00-x08x10x0bx0cx0e-x19x7f]'. '| [x00-x7f] [X80-xbf]+'. '| ([xc0xc1]| [Xf0-xff]) [X80-xbf]*'. '| [XC2-XDF] ((?! [X80-XBF]) | [X80-XBF] {2,})'. '| [Xe0-xef] ([X80-XBF] (?! [X80-XBF]) | (?! [X80-XBF] {2}) | [X80-XBF] {3,}) /S', '?', $some _string);//reject overly long 3 byte sequences and UTF-16 surrogates and replace with?$some _string = Preg_replace ('/XE0[X80-X9F][X80-XBF]'. '|xed[xa0-xbf][x80-xbf]/s','?', $some _string);

PHP removes illegal UTF-8 characters

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.