php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34105 htmlentities(chr(198).chr(146),1,'utf8') returns Α
Submitted: 2005-08-12 18:28 UTC Modified: 2005-08-13 00:24 UTC
Votes:1
Avg. Score:2.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: nospamplease at veganismus dot ch Assigned:
Status: Closed Package: Unknown/Other Function
PHP Version: 5.0.4 OS: Windows NT 5.2 build 379
Private report: No CVE-ID: None
 [2005-08-12 18:28 UTC] nospamplease at veganismus dot ch
Description:
------------
i think ƒ (aka ƒ aka ƒ) is converted to a nonapplicable character (Α) when converting from UTF-8.

This is similar to the bug #32063.

Reproduce code:
---------------
<?
header('Content-Type: text/html; charset=utf8');
$chr = uft8_chr(402);
echo 'UTF-8-Character: '.$chr;
echo ' ('.ord($chr[0]).'/'.ord($chr[1]).')';
echo '<br>Actual result: ';
$str = htmlentities($chr,1,'utf-8');
echo $str;
echo '<br>Actual result (source): ';
echo htmlspecialchars($str);
echo '<br>Expected result: &fnof;<br>Expected result (source): &amp;fnof;';

function uft8_chr($num){
  if($num<128)return chr($num);
  if($num<2048)return chr(($num>>6)+192).chr(($num&63)+128);
  if($num<65536)return chr(($num>>12)+224).chr((($num>>6)&63)+128).chr(($num&63)+128);
  if($num<2097152)return chr(($num>>18)+240).chr((($num>>12)&63)+128).chr((($num>>6)&63)+128) .chr(($num&63)+128);
  return '';
 }
?>

Expected result:
----------------
"&fnof;" (or "&#402;")

Actual result:
--------------
"&Alpha;"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-12 22:40 UTC] sniper@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.



 [2005-08-12 22:55 UTC] nospamplease at veganismus dot ch
i also testet it on my personal computer (PHP/5.0.2 on Mandrake 10) and the actual result is "&nbsp;" which is just as strange. the same goes for html_entity_decode()!
other characters that are not convertet as expected: 
&#400; (&#400;)
&#978; (&#978;)
&#982; (&#982;)
  
also characters with a very high ordinal number are not convertet at all. i'd expect "&#7820;" (X with diaeresis) to be convertet to &#7820;

then i testet it on PHP/4.4.0 (RedHat Linux) and the result was correct!
 [2005-08-12 23:24 UTC] sniper@php.net
I could ask again, but as you're obviously not giving the information we need, I'll simply bogus this next..
Please read the document about "How to report a bug" couple of times..


 [2005-08-13 00:24 UTC] nospamplease at veganismus dot ch
so what would you need to know? i gave you a code to reproduce it, information about what i expect and what i get.
i tested this on another linux system using 5.0.4 (Jun 23 2005 13:03:04) the character was not convertad at all (which is better than converting it to something else). i guess it only converts ASCII characters (<256).

i'm gonna keep this closed now since the problem is not so 
important. but it sure is (was?) an error in the html  translation table.

PS: It's "be excellent to each other" not "be excellent to them"
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 21 15:01:34 2024 UTC