Http_output

Hi everyone,

HTTP output, if I understand correctly, is to convert character
encodings from what PHP is outputting to some other specified format.
This could be used, for example, if your PHP source is stored in UTF-8,
and you wish (for some reason) to output in UCS-2. Is this correct?
Where else would this feature be used?

Thanks

Taras
Taras_96 [ Mi, 24 Januar 2007 11:45 ] [ ID #1606651 ]

Re: Http_output

"Taras_96" <taras.di [at] gmail.com> wrote in message
news:1169635555.652358.316260 [at] h3g2000cwc.googlegroups.com...
| Hi everyone,
|
| HTTP output, if I understand correctly, is to convert character
| encodings from what PHP is outputting to some other specified format.
| This could be used, for example, if your PHP source is stored in UTF-8,
| and you wish (for some reason) to output in UCS-2. Is this correct?
| Where else would this feature be used?
|
| Thanks
|
| Taras


oddly put question. 'http output' is not a php function. there are
individual functions that allow you to format data in a variety of formats
from utf-8 to base 64, etc.. the answer to your specific question is, no. as
for using the other formatting types/functions...they may be required in
order for you to interact with a database or to format a binary file so a
browser can receive it and handle it properly - as in, base64 encoding an
executable where the browser should ask if it should be saved, run, etc.

hth
Steve [ Mi, 24 Januar 2007 22:09 ] [ ID #1606659 ]

Re: Http_output

> oddly put question. 'http output' is not a php function. there are
> individual functions that allow you to format data in a variety of formats
> from utf-8 to base 64, etc.. the answer to your specific question is, no.


That makes it a bit clearer. However, this next code snippet explains
what I was trying to get at (it's from the PHP website):

"Be aware that the *strings in your source files must match the
encoding you specify by mb_internal_encoding*. It appears the Parser
loads raw bytes from the file and refers to its internal encoding to
determine their actual encoding.

To demonstrate, the following outputs as espected when the /source/
file is Latin-1 encoded:

<?php
mb_internal_encoding("iso-8859-1");
mb_http_output( "UTF-8" );
ob_start("mb_output_handler");

echo "üöä<br/>";

?>üöä"

"
So, HTTP output as I understand it, assumes that the output it received
is in a certain encoding (indicated by the internal encoding), and
converts it to whatever output is set by the mb_http_output function,
correct?

I admit that my original message wasn't that clear - 'if your PHP
source is stored' should have read something like 'if the output from
your PHP function is UTF-8'. So, back to my original question, if all
of PHP output was UTF-8, could I use mb_http_output and output
buffering to deliver this to the browser as UCS-2 by the following:

mb_internal_encoding("UTF-8");
mb_http_output("UCS-2");
ob_start("mb_output_handler");


One other thing, the term 'internal encoding' is used quite often:

"If encoding is omitted, internal character encoding is used."
(http://www.php.net/manual/en/function.mb-strlen.php)

Is this simply some variable related to the mb package that indicates,
if no other encoding is specified, the encoding of the strings it
receives?

Thanks

Taras



> as
> for using the other formatting types/functions...they may be required in
> order for you to interact with a database or to format a binary file so a
> browser can receive it and handle it properly - as in, base64 encoding an
> executable where the browser should ask if it should be saved, run, etc.
>
> hth
Taras_96 [ Do, 25 Januar 2007 03:18 ] [ ID #1608115 ]

Re: Http_output

"Taras_96" <taras.di [at] gmail.com> wrote in message
news:1169691534.324946.170590 [at] q2g2000cwa.googlegroups.com...


> oddly put question. 'http output' is not a php function. there are
> individual functions that allow you to format data in a variety of formats
> from utf-8 to base 64, etc.. the answer to your specific question is, no.


That makes it a bit clearer. However, this next code snippet explains
what I was trying to get at (it's from the PHP website):

"Be aware that the *strings in your source files must match the
encoding you specify by mb_internal_encoding*. It appears the Parser
loads raw bytes from the file and refers to its internal encoding to
determine their actual encoding.

To demonstrate, the following outputs as espected when the /source/
file is Latin-1 encoded:

<?php
mb_internal_encoding("iso-8859-1");
mb_http_output( "UTF-8" );
ob_start("mb_output_handler");

echo "üöä<br/>";

?>üöä"

"
So, HTTP output as I understand it, assumes that the output it received
is in a certain encoding (indicated by the internal encoding), and
converts it to whatever output is set by the mb_http_output function,
correct?

=== gotcha now. yes, is the answer.

I admit that my original message wasn't that clear - 'if your PHP
source is stored' should have read something like 'if the output from
your PHP function is UTF-8'. So, back to my original question, if all
of PHP output was UTF-8, could I use mb_http_output and output
buffering to deliver this to the browser as UCS-2 by the following:

mb_internal_encoding("UTF-8");
mb_http_output("UCS-2");
ob_start("mb_output_handler");

=== yes, you should be able to do that. what does you callback do?

One other thing, the term 'internal encoding' is used quite often:

"If encoding is omitted, internal character encoding is used."
(http://www.php.net/manual/en/function.mb-strlen.php)

Is this simply some variable related to the mb package that indicates,
if no other encoding is specified, the encoding of the strings it
receives?

=== it means that a default encoding is assumed and is used to interpret any
string being parsed. i think you got it if i understand what you're saying
here. i just restated it to see if you feel we're on the same page.

cheers
Steve [ Do, 25 Januar 2007 05:40 ] [ ID #1608121 ]

Re: Http_output

Excellent it's all clear now

> I admit that my original message wasn't that clear - 'if your PHP
> source is stored' should have read something like 'if the output from
> your PHP function is UTF-8'. So, back to my original question, if all
> of PHP output was UTF-8, could I use mb_http_output and output
> buffering to deliver this to the browser as UCS-2 by the following:
>
> mb_internal_encoding("UTF-8");
> mb_http_output("UCS-2");
> ob_start("mb_output_handler");
>
> === yes, you should be able to do that. what does you callback do?
>

do you mean mb_output_handler? "mb_output_handler() converts characters
in output buffer from internal character encoding to HTTP output
character encoding."

Taras
Taras_96 [ Do, 25 Januar 2007 11:06 ] [ ID #1608127 ]
PHP » alt.php » Http_output

Vorheriges Thema: outputting multi-dim array
Nächstes Thema: Re: Any Intelligent Thoughts On This?