#50693 [NEW]: UTF-8 charachters not displayed correctly in browser

From: Date: Fri, 08 Jan 2010 16:46:17 +0000
Subject: #50693 [NEW]: UTF-8 charachters not displayed correctly in browser
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-146437@lists.php.net to get a copy of this message
From:             ilian dot box at gmail dot com
Operating system: Windows XP SP3
PHP version:      5.3.1
PHP Bug Type:     *Unicode Issues
Bug description:  UTF-8 charachters not displayed correctly in browser

Description:
------------
My application runs on Apache 2.2 with MySQL 5.1.34-community database
server and PHP 5.3.1.

Prior to switching to PHP 5.3.1 I had PHP 5.2.9-2 and did NOT experience
the problem I am descibing now.

My database tables store text in UTF-8 encoding. Before being stored to
the database, the text is converted to UTF-8.

The problem is related to failing to properly display Cyrillic text in the
browser. Instead, the text is displayed as is in UTF-8, i.e. Лили
Иванова.
By using utf8_decode() I've managed to display correctly most of the
lowercase characters and few of the uppercase ones. Many are not recognized
and are substituted with a rhomb and a quastion mark.

I have to point out that this problem did not exist when I was running PHP
5.2.9-2. All Cyrillic text was properly displayed.

I have tried the following in any combinations without success:
    mb_internal_encoding("UTF-8");
    mb_http_input('UTF-8');
    mb_language('uni');
    mb_regex_encoding('UTF-8');
    mb_detect_order("UTF-8,ASCII");
    ob_start('mb_output_handler');


Reproduce code:
---------------
<?php
	header("Content-type: text/html; charset=utf-8");
	
	/*	$string1 represents the value taken from the database.
		Unfortunately when rendering this string in code by hardcoding as it is
now, but not retrieving it 
		from the database, still does not display correctly (it must be Лили
Иванова).
	*/ 
	$string1 = "Лили Иванова"; 
	
	$string2 = "Лили Иванова; // The string as it should be
displayed
	
	echo $string1;
	echo '<br>';
	echo $string2; 
	echo '<br>';
	echo utf8_decode($string1); // Partial solution	
?>

Expected result:
----------------
The value of the variable $string1 should be displayed as Лили
Иванова

Actual result:
--------------
Лили Иванова

-- 
Edit bug report at http://bugs.php.net/?id=50693&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=50693&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=50693&r=trysnapshot53
Try a snapshot (PHP 6.0):            http://bugs.php.net/fix.php?id=50693&r=trysnapshot60
Fixed in SVN:                        http://bugs.php.net/fix.php?id=50693&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50693&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=50693&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=50693&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=50693&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=50693&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=50693&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=50693&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=50693&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=50693&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=50693&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=50693&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=50693&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=50693&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=50693&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=50693&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=50693&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=50693&r=mysqlcfg



Thread (2 messages)

« previous php.bugs (#146437) next »