php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29318 Can't encode to HTML Entities from UTF-8
Submitted: 2004-07-22 11:08 UTC Modified: 2004-10-16 01:00 UTC
Votes:34
Avg. Score:4.8 ± 0.6
Reproduced:9 of 16 (56.2%)
Same Version:7 (77.8%)
Same OS:5 (55.6%)
From: atlantisboydn at yougotmail dot com Assigned:
Status: No Feedback Package: mbstring related
PHP Version: 5.0.0 OS: Windows XP SP1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: atlantisboydn at yougotmail dot com
New email:
PHP Version: OS:

 

 [2004-07-22 11:08 UTC] atlantisboydn at yougotmail dot com
Description:
------------
The following script works fine with PHP 4.3.x, but the returned string don't output in HTML-Entities format in PHP 5.0.0 

$str = mb_convert_encoding($str, "HTML-ENTITIES","UTF-8");


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-23 03:30 UTC] moriyoshi@php.net
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.


<?php
$escaped = html_entity_decode('&euro;a&auml;', 
ENT_QUOTES, 'UTF-8');
var_dump($escaped);
var_dump(mb_convert_encoding($escaped, 'HTML-ENTITIES', 
'UTF-8'));
?>

string(6) "?a?"
string(13) "&euro;a&auml;"

Works fine here.
 [2004-07-23 15:09 UTC] atlantisboydn at yougotmail dot com
$mbstring_cfgs = array(
	'zlib.output_compression'       => '1',
	'zlib.output_compression_level' => '9',
	'mbstring.detect_order'         => 'UTF-8',
	'mbstring.http_input'           => 'UTF-8',
	'mbstring.http_output'          => 'UTF-8',
	'mbstring.internal_encoding'    => 'UTF-8',
	'mbstring.script_encoding'      => NULL,
	'mbstring.substitute_character' => NULL					
);

foreach( $mbstring_cfgs as $k => $v )
{
	ini_set ($k,$v);
}
$a = @$_POST['txt'];
$a = mb_convert_encoding($a, 'UTF-8','SJIS');
$a = mb_convert_encoding($a, 'HTML-ENTITIES','UTF-8');
echo $a;
=====================================================
Step One : Converting a SJIS encoded string to UTF-8 string . This step is good , nothing trouble appeared.
Step Two : When convert UTF-8 string ( or whatever multi-byte string ) to HTML ENTITIES . PHP 5.0.0 return a wrong string with uncomplete entities and strange characters.

I don't face this problem in PHP 4.3.3 RC3.
 [2004-07-24 11:15 UTC] atlantisboy at yougotmail dot com
I also notice that , i retried many times with the same setting .

+Apache1.3.31 , PHP4.3.8
+Apache1.3.31 , PHP5.0.0
+Apache2 , PHP5.0.0
+Apache2 , PHP4.3.8
+Omni 3 Alpha 3 , PHP4.3.8
+Omni 3 Alpha 3 , PHP5.0.0
on Windows XP (SP1) computers and the problems still remain the same when i use PHP5.0.0 . I believe it's a bug and hope the problem will be resolved.
 [2004-07-31 12:41 UTC] johnmcklein at hotmail dot com
I also face this problem , how to fix it ?
 [2004-07-31 12:49 UTC] atlantisboy at yougotmail dot com
I really don't why noone consider this bug ???
 [2004-08-02 18:08 UTC] ross at golder dot org
This sounds like a duplicate of :

http://bugs.php.net/bug.php?id=25670

I'm still struggling with this one.
 [2004-10-08 16:11 UTC] moriyoshi@php.net
Hi there.

(1) $a = mb_convert_encoding($a, 'UTF-8','SJIS');
(2) $a = mb_convert_encoding($a, 'HTML-ENTITIES','UTF
-8');

Assuming you got correct result from example (1), you 
seem to be converting a sequence of SJIS-encoded data 
into HTML-ENTITIES while setting the source encoding to 
"UTF-8" in example (2), which will never produce correct 
result.

It may be a bit too late to say, though...

 [2004-10-16 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2008-05-05 17:37 UTC] pieroconti182 at hotmail dot com
yeah, i have a bug with that, when i want to do that if(htmlentities($recado) !== $recado )
but, if i use ? or ?, this code convert that to entities, and i dont want this.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 14:01:30 2025 UTC