Edit report at https://bugs.php.net/bug.php?id=62516&edit=1

 ID:                 62516
 User updated by:    pl at mygrworld dot com
 Reported by:        pl at mygrworld dot com
 Summary:            Impossible to display Unicode names
 Status:             Not a bug
 Type:               Bug
 Package:            mbstring related
 Operating System:   Linux
 PHP Version:        5.3.14
 Block user comment: N
 Private report:     N

 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------
[2012-07-09 13:52:33] [email protected]

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 
http://dev.mysql.com/doc/refman/5.5/en/charset-database.html and in the user 
comments at the bottom it shows you how to check the current encoding.

------------------------------------------------------------------------
[2012-07-09 13:06:49] pl at mygrworld dot com

Description:
------------
---
>From manual page: http://www.php.net/function.print
---
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:
---------------
<?php
setlocale(LC_ALL,"se_NO.utf8");
$query = "SELECT town, state FROM data_table WHERE town_id = 1";
$result=mysql_query($query, $sql_id);
$town=mysql_fetch_assoc($result));
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd";>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<?=$town['town'];?><br>
<? echo $town['state'];?>
</body>
</html>

Expected result:
----------------
Borås
Västra Götaland

Actual result:
--------------
Bor�s
V�stra G�taland


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



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

Reply via email to