Re: mb_string and ob_gzhandler() question

Moriyoshi Koizumi <[email protected]>
Newsgroups gmane.comp.php.internationalization
Message-ID <20030530235959DQrAz#@at.wakwak.com>
Hi,

Jean-Christian Imbeault <[email protected]> wrote:

> I remember reading somewhere a while back that the where problems with 
> using mb_string and setting output_handler in php.ini but I can't seem 
> to find anything in the PHP documentation that says it's a bad idea.
>
> I'm thinking of installing either ob_gzhanlder() or my own 
> output_handler (which would tidy op the HTML using Tidy and then gzip 
> the output). However my PHP installation is set up to use mb_string 
> (mbstring.encoding_translation = On).

Just for clarification:

1. mbstring.encoding_translation has nothing to do 
with mb_output_handler indeed. It only affects form processing behaviour, 
while mb_output_handler converts the output encoding from 
internal_encoding to http.output. The following diagram illustrates 
how the mbstring extension works in the script execution.

[FORM INPUT] (mbstring.http_input)
       |
       | conversion (if mbstring.encoding_translation=on)
       |
[SCRIPT VARIABLES] (mbstring.internal_encoding)
       |
       | conversion (if output_handler is set to "mb_output_handler")
       |
[SCRIPT OUTPUT TO THE BROWSER] (mbstring.http_output)

2. Output encoding conversion can be achieved by 
putting ob_start('mb_output_handler') at the top of your 
script as output_handler directive actually instructs php to does the same 
operation to the output buffering facility at the start of script 
execution.

3. It's not possible to add ob_gzhandler() to the output handler stack 
before mb_output_handler(), because it doesn't make sense at all to 
transform the data already gzip-encoded, which is irrelevant to any 
"human-readable" encodings, by mb_output_handler(). But this restriction
is not documented yet as far as I know.

<?php
/* this works */
ob_start('ob_gzhandler');
ob_start('mb_output_handler');
?>

<?php
/* this doesn't work */
ob_start('mb_output_handler');
ob_start('ob_gzhandler');
?>

> Is there still (if there ever was) a problem with using mb_string and 
> setting up my own output handler?

How did you set up the output handlers in your script? I didn't ever
encountered a problem with any combos of mb_output_handler() and a custom 
output handler.

Regards,

Moriyoshi


-- 
PHP Internationalization Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.