Page 1 of 1

Cannot compare with unicode input values

Posted: Wed Aug 09, 2006 8:47 am
by dibyendrah
Hello,
I am trying to compare the unicode devangari string with users input. What I did was checking the constant values with user's input. It's not working with unicode input of devanagari but when I compare with english input it's working.

Code: Select all

$input_user = $HTTP_POST_VARS["answer_nepali"];
$check1 = "१२३४५"; //devanagari value for 12345
if($input_user == $check1){
	print "correct answer!";
}
In above script, even though the input is similar to $check1 variable, it's not going inside the if condition.

What may be the problem?

Do I need to change the php configuration file ?

Hoping to get the response soon !

Dibyendra

Posted: Wed Aug 09, 2006 9:00 am
by Chris Corbyn
Is the encoding of your HTML web page where the user provides input set to UTF-8 ?

Posted: Wed Aug 09, 2006 9:17 am
by CoderGoblin
If you have checked everything else....

strcoll
utf8_encode
utf8_decode

as well as checking your locale settings.

Posted: Wed Aug 09, 2006 12:45 pm
by dibyendrah
thank you all for your replies. But the Problem is that the unicode value was in &123456#; format so it couldn't t compare with user's input.

cheers,
Dibyendra

Posted: Wed Aug 09, 2006 1:18 pm
by Chris Corbyn
dibyendrah wrote:thank you all for your replies. But the Problem is that the unicode value was in &123456#; format so it couldn't t compare with user's input.

cheers,
Dibyendra
Do you *need* to have that comparison as entities? html_entity_decode() may help.

Posted: Thu Aug 10, 2006 1:40 am
by dibyendrah
html_entity_decode() might also help but we have to encode user's input to html_entity again. I saved the file as utf8 encoding and it helped me.