#50693 [Opn->Bgs]: UTF-8 characters not displayed correctly in browser

From: Date: Sat, 09 Jan 2010 18:40:23 +0000
Subject: #50693 [Opn->Bgs]: UTF-8 characters not displayed correctly in browser
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-146489@lists.php.net to get a copy of this message
 ID:               50693
 Updated by:       jani@php.net
 Reported By:      ilian dot box at gmail dot com
-Status:           Open
+Status:           Bogus
-Bug Type:         *Unicode Issues
+Bug Type:         *General Issues
 Operating System: Windows XP SP3
 PHP Version:      5.3.1
 New Comment:

First of all: your script is crap. Please provide a script that
actually shows your problem. And check your mysql settings..that's where
the problem really is.


Previous Comments:
------------------------------------------------------------------------

[2010-01-08 16:46:17] ilian dot box at gmail dot com

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 this bug report at http://bugs.php.net/?id=50693&edit=1



Thread (2 messages)

« previous php.bugs (#146489) next »