From 4378a8450399a4c7507fe813a41240f35906ab69 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 4 May 2007 12:22:04 +0000 Subject: [PATCH] "fix for bug #445: xmlrpc utf-8 encoding error Thanks to a fix from Eugene Pivnev" --- phpgwapi/inc/xml_functions.inc.php | 42 +++++++----------------------- 1 file changed, 10 insertions(+), 32 deletions(-) diff --git a/phpgwapi/inc/xml_functions.inc.php b/phpgwapi/inc/xml_functions.inc.php index 66c9e2626d..c9e02573c6 100644 --- a/phpgwapi/inc/xml_functions.inc.php +++ b/phpgwapi/inc/xml_functions.inc.php @@ -191,42 +191,20 @@ * into their equivalent 'charset entity'. Charset entities enumerated this way * are independent of the charset encoding used to transmit them, and all XML * parsers are bound to understand them. + * + * @author Eugene Pivnev */ function xmlrpc_encode_entities($data) { - $length = strlen($data); - $escapeddata = ""; - for($position = 0; $position < $length; $position++) - { - $character = substr($data, $position, 1); - $code = Ord($character); - switch($code) - { - case 34: - $character = """; - break; - case 38: - $character = "&"; - break; - case 39: - $character = "'"; - break; - case 60: - $character = "<"; - break; - case 62: - $character = ">"; - break; - default: - if($code < 32 || $code > 159) - { - $character = ("&#".strval($code).";"); - } - break; - } - $escapeddata .= $character; + $convmap = array(0, 0x1F, 0, 0xFFFF, 0x80, 0xFFFF, 0, 0xFFFF); + $encoding = $GLOBALS['egw']->translation->system_charset; + mb_regex_encoding($encoding); + $pattern = array('<', '>', '"', '\''); + $replacement = array('<', '>', '"', '''); + for ($i=0; $i