|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62516 Impossible to display Unicode names
Submitted: 2012-07-09 13:06 UTC Modified: 2012-07-09 16:03 UTC
From: pl at mygrworld dot com Assigned:
Status: Not a bug Package: mbstring related
PHP Version: 5.3.14 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
36 + 17 = ?
Subscribe to this entry?

 [2012-07-09 13:06 UTC] pl at mygrworld dot com
From manual page:
A BOM mark is present at the top of the PHP script, the locale is set to UTF-8, 
as is the HTML Content Type. In Apache, the charset is also set to utf8.

When Unicode characters are requested from MySQL, neither the echo or print 
functions display the characters correctly within the HTML code. However, if the 
characters are written directly in the HTML, they are displayed correctly.

Data is requested from the MySQL database using mysql_query and 
mysql_fetch_assoc (or_array) into a variable (e.g. $var). A variable dump is 
made of the data retrieved from the database, which shows the required data in 
the format wanted. 

However, using "<?php echo $var[0]; ?>", "<?php print $var[0]; ?>" or "<?
=$var[0];?>" does not get the required result in the middle of the HTML code.

Test script:
$query = "SELECT town, state FROM data_table WHERE town_id = 1";
$result=mysql_query($query, $sql_id);
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<? echo $town['state'];?>

Expected result:
Västra Götaland

Actual result:
V�stra G�taland


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-07-09 13:52 UTC]
-Status: Open +Status: Not a bug
 [2012-07-09 13:52 UTC]
PHP doesn't do anything to the bytes that come out of MySQL here. It is a 
straight binary-safe pass through so the problem can't be in PHP. I suspect you 
haven't set the encoding on your MySQL table correctly. See and in the user 
comments at the bottom it shows you how to check the current encoding.
 [2012-07-09 15:49 UTC] pl at mygrworld dot com
I checked that and actually dumped the variable value after it had been collected 
from the database. It was in the correct format. There has to have been a change 
between it being read from the database and written to disk, before it was then 
included in the HTML for display.
 [2012-07-09 16:03 UTC]
Like I said, PHP doesn't touch it. Whatever comes back from MySQL is what will 
end up in your PHP variable.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 09:01:27 2024 UTC