#39332 [NEW]: Wrong character encoding from external program output

From: Date: Wed, 01 Nov 2006 13:55:38 +0000
Subject: #39332 [NEW]: Wrong character encoding from external program output
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-104253@lists.php.net to get a copy of this message
From: herbert dot fischer at gmail dot com Operating system: Red Hat ELAS4 Upd3 PHP version: 5.1.6 PHP Bug Type: Program Execution Bug description: Wrong character encoding from external program output Description: ------------ PHP is assuming character encoding from external executed svn client, as ASCII. Even when external program returns ISO-8859-1 encoded string, PHP "parses" the encoded string as ASCII, expanding accented characters as literal string form and not their binary form. For example: an output like "Acentuação" turns to be a string in literal form "Acentua?\195?\167?\195?\163o/". Reproduce code: --------------- Import some accented file or folders into a subversion repository. Is it possible to convert the output to utf-8 using the command bellow: # svn list 'file:////home/svn/herbert/' | iconv -tutf-8 But not when from PHP: <?php $cmd = "svn list 'file:////home/svn/herbert/'"; $out = shell_exec($cmd); $res = unpack('c*', $out); var_dump($res); ?> var_dump reports: array(29) { [1]=> int(65) [2]=> int(99) [3]=> int(101) [4]=> int(110) [5]=> int(116) [6]=> int(117) [7]=> int(97) [8]=> int(63) [9]=> int(92) [10]=> int(49) [11]=> int(57) [12]=> int(53) [13]=> int(63) [14]=> int(92) [15]=> int(49) [16]=> int(54) [17]=> int(55) [18]=> int(63) [19]=> int(92) [20]=> int(49) [21]=> int(57) [22]=> int(53) [23]=> int(63) [24]=> int(92) [25]=> int(49) [26]=> int(54) [27]=> int(51) [28]=> int(111) [29]=> int(47) } So it's not possible to convert the string to other character set, since it's invalid. Expected result: ---------------- It's expected to PHP store the string as it's original binary format. array(10) { [1]=> int(65) [2]=> int(99) [3]=> int(101) [4]=> int(110) [5]=> int(116) [6]=> int(117) [7]=> int(97) [8]=> int(-25) [9]=> int(-29) [10]=> int(111) } -- Edit bug report at http://bugs.php.net/?id=39332&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=39332&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=39332&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=39332&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=39332&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=39332&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=39332&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=39332&r=needscript Try newer version: http://bugs.php.net/fix.php?id=39332&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=39332&r=support Expected behavior: http://bugs.php.net/fix.php?id=39332&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=39332&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=39332&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=39332&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39332&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=39332&r=dst IIS Stability: http://bugs.php.net/fix.php?id=39332&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=39332&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=39332&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=39332&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=39332&r=mysqlcfg

« previous php.bugs (#104253) next »