[Mapbender-commits] r1508 - trunk/mapbender/http/classes
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed Jul 18 10:56:27 EDT 2007
Author: christoph
Date: 2007-07-18 10:56:27 -0400 (Wed, 18 Jul 2007)
New Revision: 1508
Modified:
trunk/mapbender/http/classes/class_administration.php
Log:
added central char_encode function
Modified: trunk/mapbender/http/classes/class_administration.php
===================================================================
--- trunk/mapbender/http/classes/class_administration.php 2007-07-18 14:54:52 UTC (rev 1507)
+++ trunk/mapbender/http/classes/class_administration.php 2007-07-18 14:56:27 UTC (rev 1508)
@@ -921,5 +921,29 @@
return false;
}
}
+
+ function is_utf8($string) {
+ return preg_match('%(?:
+ [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
+ |\xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
+ |[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
+ |\xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
+ |\xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
+ |[\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
+ |\xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
+ )+%xs', $string);
+ }
+
+ function char_encode($data) {
+ if (CHARSET == "UTF-8") {
+ if ($this->is_utf8($data)) {
+ return $data;
+ }
+ return utf8_encode($data);
+ }
+ return $data;
+ }
}
+
+
?>
More information about the Mapbender_commits
mailing list