PHP Unicode help needed...
Moderator: General Moderators
PHP Unicode help needed...
Hi,
I am using Unicode method for Tamil Language. These Tamil words are stored in database like ୱ for 'அ'.
When i execute a query to get the values from database , i am getting zero rows.
SELECT * FROM table_name WHERE name = 'அ' [query is executed like this.]
But the word 'அ' is stored in database like ୱ So before i write query i need to convert the word 'அ' to ୱ
Can anyone tell me how to do this?
Thanks in advance.
I am using Unicode method for Tamil Language. These Tamil words are stored in database like ୱ for 'அ'.
When i execute a query to get the values from database , i am getting zero rows.
SELECT * FROM table_name WHERE name = 'அ' [query is executed like this.]
But the word 'அ' is stored in database like ୱ So before i write query i need to convert the word 'அ' to ୱ
Can anyone tell me how to do this?
Thanks in advance.
Re: PHP Unicode help needed...
try utf8_encode() - http://www.php.net/utf8_encode
Re: PHP Unicode help needed...
Thank you for your reply.
I tired using utf8_encode. But i am getting the same string.
For example, i submit my form after enter a work like 'அ',
i am getting the same work if i pass the word into utf8_encode.
echo $_REQUEST['word'] returns 'அ'
echo utf8_encode($_REQUEST['word']) returns the same 'அ'
any other possibility?
Thanks in advance.
I tired using utf8_encode. But i am getting the same string.
For example, i submit my form after enter a work like 'அ',
i am getting the same work if i pass the word into utf8_encode.
echo $_REQUEST['word'] returns 'அ'
echo utf8_encode($_REQUEST['word']) returns the same 'அ'
any other possibility?
Thanks in advance.
Re: PHP Unicode help needed...
The output might look the same, but that's only cause your browser understands UTF-8 encoding. If you var_dump the variable instead, you'll see it has a different length -
Code: Select all
var_dump($_REQUEST['word']);
var_dump(utf8_encode($_REQUEST['word']));
Re: PHP Unicode help needed...
Code: Select all
<html>
<body>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
</head>
<?php
if(isset($_REQUEST['submit']))
{
echo var_dump($_REQUEST['word']);
echo var_dump(utf8_encode($_REQUEST['word']));
}
?>
<form method="post">
<input type="text" name="word" />
<input type="submit" name="submit" />
</form>
</body>
</html>The output is ... (in firefox)
string(7) "?" string(7) "?"
The output is ... (in ie 7)
string(3) "?" string(6) "à®?"
What does it mean?
Re: PHP Unicode help needed...
It doesn't make sense to me, especially since I get the same results in all browsers. Did you try putting it in the query and see if it works?
Re: PHP Unicode help needed...
I am sorry. It is all my mistake.
You are right. Now i got another problem.
In the posting page i used charset iso-8859-1
and in search page i am using charset utf-8 in head tag
while i work with unicode which one is best ?
if utf-8 is best, then how can i migrate my tables?
You are right. Now i got another problem.
In the posting page i used charset iso-8859-1
and in search page i am using charset utf-8 in head tag
while i work with unicode which one is best ?
if utf-8 is best, then how can i migrate my tables?
Re: PHP Unicode help needed...
You change the character set / collation. Either through phpmyAdmin or by running the queries directly - http://dev.mysql.com/doc/refman/5.0/en/ ... table.html
Be sure to backup the tables up first.
Be sure to backup the tables up first.
Re: PHP Unicode help needed...
okay
I really appreciate your help
Thank you
I really appreciate your help
Thank you