#43777 [Opn]: htmlentities converts specialchars wrong

From: Date: Mon, 07 Jan 2008 16:13:22 +0000
Subject: #43777 [Opn]: htmlentities converts specialchars wrong
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-121109@lists.php.net to get a copy of this message
 ID:               43777
 User updated by:  klooss at serviceconnect dot biz
 Reported By:      klooss at serviceconnect dot biz
 Status:           Open
 Bug Type:         Unknown/Other Function
 Operating System: Win32 / Linux
 PHP Version:      4.4.8
 New Comment:

You can fix this bug with this code example

$str='dwadwadawd´dwadawd';
print(preg_replace("/&#(.*?);/","&#$1;",$str));

it is not so good but it's work...


Previous Comments:
------------------------------------------------------------------------

[2008-01-07 15:39:44] klooss at serviceconnect dot biz

Description:
------------
I have build an simple function to convert any string's

here the src:

function htmlconverter($str) {
        return htmlentities($str,ENT_QUOTES,'ISO-8859-15');
    }
echo ("´ ' \" `");
echo "\n";
echo htmlconverter("´ ' \" `");
/** Output
´ ' " `
´ ' " `
**/

PHP Converted the Simbol >> ´ << wrong.
as unicode in HTML &#180;
PHP Convert it in: &amp;#180;

I found the problem on "Debian Etch amd64 - php5.2.4-2", "Suse
php4.3.4" and "Win32 php5.2.3"

can anyone help my :) pls :)

thanks
Mathis Klooß (Germany)

Reproduce code:
---------------
function htmlconverter($str) {
        return htmlentities($str,ENT_QUOTES,'ISO-8859-15');
    }
echo ("´ ' \" `");
echo "\n";
echo htmlconverter("´ ' \" `");
/** Output
´ ' " `
&amp;#180; ' &quot; `
**/

Expected result:
----------------
´ ' " `
&#180; ' &quot; `



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=43777&edit=1


Thread (3 messages)

« previous php.bugs (#121109) next »