Re: WDDX and binary data
| From: | Rouvas Stathis | Date: | Sat, 15 Sep 2001 13:29:40 +0000 |
| Subject: | Re: WDDX and binary data | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-67443@lists.php.net to get a copy of this message | ||
Try base64_(en|de)code.
-Stathis.
Christopher Heschong wrote:
>
> Despite the fact that PHP's WDDX functions don't support a "binary" type,
> most binary data comes through just fine, and in fact, the WDDX serialize
> function can encode certain types of binary data, such as a null
> character: <char code='00'/>
>
> But the deserialize process dos not retain these characters. Is this a
> bug in PHP's implementation of WDDX, or is there perhaps a workaround
> available?
>
> Here's some example code that shows a WDDX packet of encoded binary data.
> The packet itself contains all of the binary data, including null
> characters, etc. The deserialized() string, however, does not.
>
> <?php
>
> $fp =
> fopen("http://www.php.net/gifs/php_logo.gif","r");
> while (!feof($fp)) {
> $str .= fread($fp, 4096);
> }
>
$str = base64_encode($str);
> $packet = wddx_serialize_value($str, "php_logo.gif");
>
> Header("Content-Type: image/gif");
>
> $str = wddx_deserialize($packet);
$str = base64_decode($str);
>
> echo $str;
>
> ?>
>
> --
> /chris/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net