Welcome Guest, Not a member yet? Register   Sign In
Arabic not displaying properly
#1

[eluser]shadowcaster[/eluser]
Hi all.

I'm building an English/Arabic website which pulls in data from a mysql database which has the Arabic stored in UTF8 encoding.

I had the good sense to encode the views and controllers in UTF8 before attempting to display the Arabic and here's an example of the output I get using Codeigniter:

114:1 قل اعوذ برب الناس
114:2 ملك الناس
114:3 اله الناس
114:4 من شر الوسواس الخناس
114:5 الذى يوسوس فى صدور الناس
114:6 من الجنه والناس

I've spent many hours trying to fix this but to no avail.

Now I wrote a standalone script to pull the data from the DB just to check it was working correctly and it is:

قل اعوذ برب الناس
ملك الناس
اله الناس
من شر الوسواس الخناس
الذى يوسوس فى صدور الناس
من الجنه والناس

So why doesn't it display properly in CI?

Thanks.
#2

[eluser]toopay[/eluser]
Did you check : Language Helper
#3

[eluser]shadowcaster[/eluser]
[quote author="toopay" date="1311340842"]Did you check : Language Helper[/quote]

Toopay, I'm not working with language files. The Arabic text I need to display is in a mysql database.
#4

[eluser]LuckyFella73[/eluser]
Did you set the charset in your header?
Code:
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />

I guess you did - just in case ...

You could try to define utf8 encoding in PHP header too. I once had a case
when that was necessary to get the chars displayed correctly.
#5

[eluser]toopay[/eluser]
@shadowcaster, did you only run your site in one languange?
#6

[eluser]shadowcaster[/eluser]
I reckon it's something to do with how the text is read in from the database using the db class. This is the query I'm running:

Code:
$this->db->from('quran')
         ->where('sura_num', $chapter_id);

foreach($this->db->get()->result() AS $row){
            $output .= '<div class="readresult">';
            $output .= '<span class="quransuranum">' . $row->sura_num . ':' . $row->aya_num . '</span> ';
            $output .= '<span class="quranverse">' . $row->aya . '</span></div>';
        }

I've tried outputting it directly through the controller and everything is UTF8 and the headers and even meta charset (HTML5) is UTF8 but I still have this problem. I think it's something in the db class. It's not the database content itself because I've written a standalone script and that displays the Arabic without any issues.
#7

[eluser]InsiteFX[/eluser]
You can try this, it should be the one called!
Code:
if (function_exists('mysql_set_charset'))
{
    mysql_set_charset('utf8', $db);
}
else
{
    mysql_query("SET NAMES 'utf8'", $db);
}

InsiteFX
#8

[eluser]shadowcaster[/eluser]
^ Unfortunately, that didn't do anything either.
#9

[eluser]Zaher Ghaibeh[/eluser]
the problem is in your database , your database tables must be UTF-8 ..
since in your database.php file you have set the charset to UTF-8
Code:
$db['dev']['char_set'] = 'utf8';
$db['dev']['dbcollat'] = 'utf8_general_ci';

or you have to change those options to satisfy your tables charset




Theme © iAndrew 2016 - Forum software by © MyBB