[Pkg-owncloud-commits] [php-sabre-vobject] 08/32: Simpler way to check UTF-8.
David Prévot
taffit at moszumanska.debian.org
Fri Nov 28 22:27:08 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository php-sabre-vobject.
commit 98d3426ba6d660739c25e47e05ad7ae13f8926d9
Author: Ivan Enderlin <ivan.enderlin at hoa-project.net>
Date: Tue Nov 11 17:04:19 2014 +0100
Simpler way to check UTF-8.
It avoids to call the `mb_check_encoding` function.
---
lib/StringUtil.php | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/lib/StringUtil.php b/lib/StringUtil.php
index 98bd7c1..bca717a 100644
--- a/lib/StringUtil.php
+++ b/lib/StringUtil.php
@@ -19,17 +19,12 @@ class StringUtil {
*/
static public function isUTF8($str) {
- // First check.. mb_check_encoding
- if (!mb_check_encoding($str, 'UTF-8')) {
- return false;
- }
-
// Control characters
- if (preg_match('%(?:[\x00-\x08\x0B-\x0C\x0E\x0F])%', $str)) {
+ if (preg_match('%[\x00-\x08\x0B-\x0C\x0E\x0F]%', $str)) {
return false;
}
- return true;
+ return (bool)preg_match('%%u', $str);
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabre-vobject.git
More information about the Pkg-owncloud-commits
mailing list