Skip to content

Commit 1269578

Browse files
committed
Merge pull request #150 from frankmayer/devel
Leaner and meaner regex utf-8 check :)
2 parents 641316b + e65f9fe commit 1269578

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

lib/triagens/ArangoDb/Connection.php

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -538,20 +538,7 @@ private function doBatch($method, $request)
538538
*/
539539
public static function detect_utf($string)
540540
{
541-
if (preg_match(
542-
'%^(?:
543-
[\x09\x0A\x0D\x20-\x7E] # ASCII
544-
| [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
545-
| \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
546-
| [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
547-
| \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
548-
| \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
549-
| [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
550-
| \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
551-
)*$%xs',
552-
$string
553-
)
554-
) {
541+
if (preg_match("//u", $string)) {
555542
return true;
556543
} else {
557544
return false;

0 commit comments

Comments
 (0)