#44513 [Opn->Fbk]: htmlspecialchars charset doesn't work

From: Date: Wed, 26 Mar 2008 11:52:04 +0000
Subject: #44513 [Opn->Fbk]: htmlspecialchars charset doesn't work
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-123654@lists.php.net to get a copy of this message
ID: 44513 Updated by: jani@php.net Reported By: juan at multiporte dot com dot br -Status: Open +Status: Feedback Bug Type: Strings related Operating System: WinXP PHP Version: 5.2.5 -Assigned To: +Assigned To: fb-req-jani New Comment: Eh..so you're passing non-utf8 to the function and use UTF-8 as charset and expect it to work? How is this a bug? Previous Comments: ------------------------------------------------------------------------ [2008-03-25 22:32:24] juan at multiporte dot com dot br Well, I tried using snap version and nothing... Let's go to tecnical infos: PHP Code: <?php var_dump(htmlspecialchars('março', ENT_QUOTES, 'UTF-8')); var_dump(utf8_encode('março')); ?> Result: string(0) "" string(6) "março" PHP version: PHP Version 5.2.6RC3-dev PHP extensions: curl, gd2, gettext, mbstring, mcrypt, mysql, mysqli, openssl, pdo, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, soap, sockets, svn, xmlrpc, xsl System: Windows NT ***** 5.1 build 2600 Server API: Apache 2.0 Handler Apache version: Apache/2.0.59 (Win32) PHP/5.2.6RC3-dev SVN/1.4.4 DAV/2 Apache modules: core mod_win32 mpm_winnt http_core mod_so mod_access mod_actions mod_alias mod_asis mod_auth mod_autoindex mod_cgi mod_dav mod_dir mod_env mod_imap mod_include mod_isapi mod_log_config mod_mime mod_negotiation mod_rewrite mod_setenvif mod_userdir mod_php5 mod_dav_svn mod_authz_svn [iconv] iconv.input_encoding = ISO-8859-1 iconv.internal_encoding = UTF-8 iconv.output_encoding = UTF-8 Apache configuration (httpd.conf): LoadModule php5_module "c:/arquiv~1/php5/php5apache2.dll" AddType application/x-httpd-php .php AddType application/x-httpd-php .php5 # configure the path to php.ini PHPIniDir "C:/arquiv~1/php5" More information about source file: The source code must be in ANSI mode for see that error. If the source file in UTF-8, work's great. ------------------------------------------------------------------------ [2008-03-25 13:25:05] jani@php.net Works just fine for me using latest CVS snapshot. Try with this: For Windows (zip): http://snaps.php.net/win32/php5.2-win32-latest.zip For Windows (installer): http://snaps.php.net/win32/php5.2-win32-installer-latest.msi But I'd guess you're just not using it properly and you're not really passing valid UTF-8 data to it.. ------------------------------------------------------------------------ [2008-03-23 20:14:03] juan at multiporte dot com dot br Description: ------------ When using htmlspecialchars with charset UTF-8 in Windows, this not display anything if have special chars. But, if I use utf8_encode function, work nice. I'm tested in Apache 2.0 and PHP 5.2.5. Reproduce code: --------------- <?php var_dump(htmlspecialchars('março', ENT_QUOTES, 'UTF-8')); ?> Expected result: ---------------- março (in UTF-8) Actual result: -------------- (empty) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=44513&edit=1

« previous php.bugs (#123654) next »