[Mapbender-commits] r1523 - trunk/mapbender/http/classes
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Fri Jul 20 11:03:30 EDT 2007
Author: christoph
Date: 2007-07-20 11:03:30 -0400 (Fri, 20 Jul 2007)
New Revision: 1523
Modified:
trunk/mapbender/http/classes/class_administration.php
trunk/mapbender/http/classes/class_wms.php
Log:
enhanced encoding determination
Modified: trunk/mapbender/http/classes/class_administration.php
===================================================================
--- trunk/mapbender/http/classes/class_administration.php 2007-07-20 13:39:07 UTC (rev 1522)
+++ trunk/mapbender/http/classes/class_administration.php 2007-07-20 15:03:30 UTC (rev 1523)
@@ -17,6 +17,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+require_once(dirname(__FILE__)."/class_mb_exception.php");
$con = db_connect(DBSERVER,OWNER,PW);
db_select_db(DB,$con);
@@ -922,7 +923,7 @@
}
}
- function is_utf8($string) {
+ function is_utf8_string($string) {
return preg_match('%(?:
[\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
|\xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
@@ -934,26 +935,39 @@
)+%xs', $string);
}
+ function is_utf8_xml($xml) {
+ return preg_match('/<\?xml[^>]+encoding="utf-8"[^>]*\?>/is', $xml);
+ }
+
+ function is_utf8 ($data) {
+ return ($this->is_utf8_xml($data) || $this->is_utf8_string($data));
+ }
+
function char_encode($data) {
if (CHARSET == "UTF-8") {
if (!$this->is_utf8($data)) {
+ $e = new mb_exception("Conversion: ISO-8859-1 to UTF-8");
return utf8_encode($data);
}
}
else {
if ($this->is_utf8($data)) {
+ $e = new mb_exception("Conversion: UTF-8 to ISO-8859-1");
return utf8_decode($data);
}
}
+ $e = new mb_exception("no conversion: is " . CHARSET);
return $data;
}
function char_decode($data) {
if (CHARSET == "UTF-8") {
if ($this->is_utf8($data)) {
+ $e = new mb_exception("Conversion: UTF-8 to ISO-8859-1");
return utf8_decode($data);
}
}
+ $e = new mb_exception("no conversion: is " . CHARSET);
return $data;
}
}
Modified: trunk/mapbender/http/classes/class_wms.php
===================================================================
--- trunk/mapbender/http/classes/class_wms.php 2007-07-20 13:39:07 UTC (rev 1522)
+++ trunk/mapbender/http/classes/class_wms.php 2007-07-20 15:03:30 UTC (rev 1523)
@@ -90,11 +90,11 @@
$this->wms_upload_url = $url;
$this->wms_id = "";
- $parser = xml_parser_create(CHARSET);
+ $parser = xml_parser_create("");
xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1);
xml_parser_set_option($parser,XML_OPTION_TARGET_ENCODING,CHARSET);
- xml_parse_into_struct($parser,$data,$values,$tags);
+ xml_parse_into_struct($parser,$this->wms_getcapabilities_doc,$values,$tags);
$code = xml_get_error_code($parser);
if ($code) {
More information about the Mapbender_commits
mailing list