Bug #62875 [Opn]: base64_encode broken with binary string
Edit report at https://bugs.php.net/bug.php?id=62875&edit=1
ID: 62875
Updated by: rasmus@php.net
Reported by: robertleglu at msn dot com
Summary: base64_encode broken with binary string
Status: Open
Type: Bug
Package: URL related
Operating System: z/OS
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
reeze, it isn't really OS-specific but rather EBCDIC-specific. We have EBCDIC
hacks in a few places, but I guess nobody bothered to make base64_encode EBCDIC-
safe.
Previous Comments:
------------------------------------------------------------------------
[2012-08-20 15:23:24] reeze dot xia at gmail dot com
I can't reproduce it.
http://3v4l.org/GIL8C
It seems a OS specific bug. and I can't get a z/OS :(
------------------------------------------------------------------------
[2012-08-20 14:29:22] robertleglu at msn dot com
Description:
------------
problem occurs on z/OS 1.11 (OS of IBM mainframe) with latest version of php for
that system.
binary strings are badly encoded with base64_encode.
rewriting my own (portable) version bypass the problem.
php version : (php_cli --version)
PHP 5.1.2 (cli) (built: Sep 28 2010 16:33:24)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
Note that z/OS works in EBCDIC, so any code that assume ascii code, ascii order
and ascii continuity is broken
Test script:
---------------
<?php
$str = chr(0x47).chr(0x49).chr(46);
echo base64_encode($str).PHP_EOL;
?>
Expected result:
----------------
R0ku
Actual result:
--------------
5fEG
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62875&edit=1
Thread (5 messages)