diff --git a/calendar/inc/class.uiforms.inc.php b/calendar/inc/class.uiforms.inc.php index 478f680aae..467bd6d073 100644 --- a/calendar/inc/class.uiforms.inc.php +++ b/calendar/inc/class.uiforms.inc.php @@ -1220,7 +1220,7 @@ class uiforms extends uical else { $GLOBALS['egw']->browser =& CreateObject('phpgwapi.browser'); - $GLOBALS['egw']->browser->content_header('event.ics','text/calendar',strlen($ical)); + $GLOBALS['egw']->browser->content_header('event.ics','text/calendar',bytes($ical)); echo $ical; $GLOBALS['egw']->common->egw_exit(); } @@ -1243,7 +1243,7 @@ class uiforms extends uical { $ical =& ExecMethod2('calendar.boical.exportVCal',$events,'2.0'/*$content['version']*/); $GLOBALS['egw']->browser =& CreateObject('phpgwapi.browser'); - $GLOBALS['egw']->browser->content_header($content['file'] ? $content['file'] : 'event.ics','text/calendar',strlen($ical)); + $GLOBALS['egw']->browser->content_header($content['file'] ? $content['file'] : 'event.ics','text/calendar',bytes($ical)); echo $ical; $GLOBALS['egw']->common->egw_exit(); } diff --git a/phpgwapi/inc/class.db_backup.inc.php b/phpgwapi/inc/class.db_backup.inc.php index eaac7732c4..10ad6280aa 100644 --- a/phpgwapi/inc/class.db_backup.inc.php +++ b/phpgwapi/inc/class.db_backup.inc.php @@ -438,7 +438,7 @@ { $this->browser = CreateObject('phpgwapi.browser'); } - $this->browser->content_header('schema-backup-'.date('YmdHi').'.inc.php','text/plain',strlen($def)); + $this->browser->content_header('schema-backup-'.date('YmdHi').'.inc.php','text/plain',bytes($def)); echo "PutLine($this->request_method.' '.$request_uri.' HTTP/'.$this->protocol_version))) { - if(($body_length = strlen($request_body))) + if(($body_length = bytes($request_body))) { $headers['Content-length'] = $body_length; } diff --git a/phpgwapi/inc/class.xmlrpc_server_epi.inc.php b/phpgwapi/inc/class.xmlrpc_server_epi.inc.php index 547f922d1e..6cc0c8166d 100644 --- a/phpgwapi/inc/class.xmlrpc_server_epi.inc.php +++ b/phpgwapi/inc/class.xmlrpc_server_epi.inc.php @@ -60,7 +60,7 @@ else { // $payload = '' . "\n" . $this->serializeDebug() . $r->serialize(); -// Header("Content-type: text/xml\r\nContent-length: " . strlen($payload)); +// Header("Content-type: text/xml\r\nContent-length: " . bytes($payload)); // print $payload; echo $r; } diff --git a/phpgwapi/inc/class.xmlrpc_server_php.inc.php b/phpgwapi/inc/class.xmlrpc_server_php.inc.php index b01c2a54dc..18575dd742 100644 --- a/phpgwapi/inc/class.xmlrpc_server_php.inc.php +++ b/phpgwapi/inc/class.xmlrpc_server_php.inc.php @@ -95,7 +95,7 @@ $payload = $GLOBALS['egw']->translation->convert("\n" . $this->serializeDebug() . $r->serialize(), $GLOBALS['egw']->translation->charset(),'utf-8'); header("Content-type: text/xml"); - header("Content-length: " . $this->bytes($payload)); + header("Content-length: " . bytes($payload)); echo $payload; } @@ -121,24 +121,6 @@ } } - /** - * mbstring.func_overload save strlen version: counting the bytes not the chars - * - * @param string $str - * @return int - */ - function bytes($str) - { - static $func_overload; - - if (is_null($func_overload)) - { - $func_overload = @extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0; - } - return $func_overload & 2 ? mb_strlen($str,'ascii') : strlen($str); - } - - /* * add a method to the dispatch map */ diff --git a/phpgwapi/inc/common_functions.inc.php b/phpgwapi/inc/common_functions.inc.php index b50c10149f..708cac8fe3 100755 --- a/phpgwapi/inc/common_functions.inc.php +++ b/phpgwapi/inc/common_functions.inc.php @@ -28,6 +28,22 @@ * because they are required to be available at the lowest level. * \***************************************************************************/ + /** + * Return the number of bytes of a string, independent of mbstring.func_overload + * AND the availability of mbstring + * + * @param string $str + * @return int + */ + function bytes($str) + { + static $func_overload; + + if (is_null($func_overload)) $func_overload = extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0; + + return $func_overload & 2 ? mb_strlen($str,'ascii') : strlen($str); + } + /** * @internal Not to be used directly. Should only be used by print_debug() */ diff --git a/phpgwapi/inc/xml_functions.inc.php b/phpgwapi/inc/xml_functions.inc.php index 58b35b4f12..b400043074 100644 --- a/phpgwapi/inc/xml_functions.inc.php +++ b/phpgwapi/inc/xml_functions.inc.php @@ -167,7 +167,7 @@ ); $payload = '' . "\n" . $r->serialize(); Header('Content-type: text/xml'); - Header('Content-length: ' . strlen($payload)); + Header('Content-length: ' . bytes($payload)); print $payload; $GLOBALS['egw']->common->phpgw_exit(False); } diff --git a/rpc.php b/rpc.php index 5ada3508c9..52ec9a5181 100644 --- a/rpc.php +++ b/rpc.php @@ -117,6 +117,6 @@ $out = $server->getResponse($input, $params); /* Return the response to the client. */ header('Content-Type: ' . $server->getResponseContentType()); -header('Content-length: ' . strlen($out)); +header('Content-length: ' . bytes($out)); header('Accept-Charset: UTF-8'); echo $out;