0

I am developing a website using urdu in codeigniter framework. I want to load urdu in my webpages but I failed every time. I send urdu to database in uni code when I am trying to access urdu data and show it in webpage it show me some other things which is in attachment. This is screenshot of webpage

I already used meta tag below

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

How can I write urdu in webpage using codeigniter framework.

Razia sultana
  • 2,168
  • 3
  • 15
  • 20
Ayaz khan
  • 153
  • 5
  • 16

3 Answers3

3

Step : 1 - Go to table structure and change collation latin1_swedish_ci to utf8_general_ci

Step : 2 - You have to include this following tag in data results pages.

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

Step :3 - Insert 'N' Prefix. Here the N stands for National language character set. Which means that you are passing an NCHAR, NVARCHAR or NTEXT value

Step :4 - PHP code displaying records form database. Before that you have to specify mysql_query() function data character set type

<?php
include('db.php');
mysql_query ("set character_set_results='utf8'"); 
$query = mysql_query("SELECT * FROM books") or die(mysql_error());
while($row=mysql_fetch_array($query))
{
echo $row['id']; // Book id 
echo $row['books_title']; // Book title
}
?>
Rana Ghosh
  • 4,514
  • 5
  • 23
  • 40
  • How can i use set character_set_results='utf8' in codeiginator – Ayaz khan Dec 14 '16 at 15:32
  • @Ayazkhan if it helped you please upvote the answer to help others. – Rana Ghosh Dec 14 '16 at 18:00
  • Codeigniter has it on database set up if you autoload database you do not need to include it like you have done https://www.codeigniter.com/user_guide/database/query_builder.html –  Dec 14 '16 at 20:42
0

Correct answer i found after a lot of research that you have to set your database table collation to utf8_general_ci and it will help you a lot.

Below line is must in your page header

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Ayaz khan
  • 153
  • 5
  • 16
0

I Just solve the problem by adding the following header in each __constructor. you may add this in parent controller

header('Content-Type: text/html; charset=utf-8');