#44945 [Opn->Bgs]: escapeshellarg removes UTF-8 multi-byte characters

From: Date: Sun, 13 Jul 2008 17:01:20 +0000
Subject: #44945 [Opn->Bgs]: escapeshellarg removes UTF-8 multi-byte characters
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-126639@lists.php.net to get a copy of this message
ID: 44945 Updated by: jani@php.net Reported By: thomas dot jarosch at intra2net dot com -Status: Open +Status: Bogus Bug Type: Strings related Operating System: Linux PHP Version: 5.2.6 New Comment: There's no automatic way. If you need to have it work with utf-8 of course you have to set the locales properly too. Or just not use UTF-8.. Previous Comments: ------------------------------------------------------------------------ [2008-05-08 12:59:36] thomas dot jarosch at intra2net dot com Thanks, that seems to work. I've inspected the environment on the server and it contains a LANG="en_US.UTF-8" variable. Is there a way I can fix this/PHP autodetects it without touching every code using escapeshellarg()? ------------------------------------------------------------------------ [2008-05-08 11:28:25] felipe@php.net Try with the code below (mandatory in the test): if (false == setlocale(LC_CTYPE, "UTF8", "en_US.UTF-8")) { die("skip setlocale() failed\n"); } ------------------------------------------------------------------------ [2008-05-08 11:08:27] thomas dot jarosch at intra2net dot com Description: ------------ Hello together, I'm seeing almost the same issue as #44564 after upgrading from PHP 5.2.5 to 5.2.6. If I execute the provided test code via php CLI, everything works as expected. Running the same code via mod_php inside Apache skips the UTF-8 multi-byte characters. I've looked at the ext/standard/exec.c code a bit and checked that my "config.log" in both PHP build directories contains "#define HAVE_MBLEN 1" so the call to php_mblen() should work. Any idea what that could be? One thing I noticed is that php_mblen() is a wrapper macro for mblen() or mbrlen() which features a slight difference in the return code (see -2 rc for details). Thanks, Thomas Reproduce code: --------------- var_dump(escapeshellarg('ä')); Expected result: ---------------- string(2) "'ä'" Actual result: -------------- string(2) "''" ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=44945&edit=1

« previous php.bugs (#126639) next »