note 55631 deleted from function.utf8-decode by cmb

From: Date: Sun, 11 Dec 2016 11:38:58 +0000
Subject: note 55631 deleted from function.utf8-decode by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-208545@lists.php.net to get a copy of this message
Note Submitter: chris at mrwsp dot com ---- A small improvement. JF Sebastian's regex for UTF-8 is not quite correct. Because code points could otherwise be coded in more than one way using UTF-8, the Standard stipulates that the shortest possible representation for a character should be used. So some 'duplicate' combinations his regex accepts are not valid UTF-8. Additionally, his regex accepts characters beyond the valid Unicode code space. The regex should be: ^([\x00-\x7f]| [\xc2-\xdf][\x80-\xbf]| [\xe0][\xa0-\xbf][\x80-xbf]| [\xe1-\xec][\x80-\xbf]{2}| [\xed][\x80-\x9f][\x80-\xbf]| [\xee-\xef][\x80-\xbf]{2}| [\xf0][\x90-\xbf][\x80-\xbf]{2}| [\xf1-\xf3][\x80-\xbf]{3}| [\xf4][\x80-\x8f][\x80-\xbf]{2}*$)

« previous php.notes (#208545) next »