Forum Moderators: coopster

Message Too Old, No Replies

php spanish character problem

         

greenCountry

4:44 pm on Jan 30, 2008 (gmt 0)

10+ Year Member



hello everyone,

This is important,I am trying to post some spanish characters from a form on a page and i am comparing those spanish characters to the same letters on the same page but on strcmp the return is not zero.I don't know what is wrong some problem with the post method i guess or strcmp i don't know....Please help....here is the code...

<html><body><?php
echo(strcmp('í',$_POST['check']));
?>

<form action="./index.php" method="post">
<input type="text" name="check">
<input type="submit" name="go" >
</form>
</body></html>

the name of the file is index.php and i am typing í in the text box before pressing submit.the result is not coming as zero but -1.The result is not coming for any of spanish or special characters like ¿,ñ,ü how to solve it that echo answer is zero.

I have searched a lot on net and finally i am coming here to get some help.

cameraman

1:26 am on Jan 31, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld, greenCountry.
I tried playing with this (I compared the string 'baño' to a posted one) and it's working ok for me. You might try looking at setlocale() [php.net] and strcoll() [php.net] as alternatives.

greenCountry

6:50 am on Feb 1, 2008 (gmt 0)

10+ Year Member



i think i got the solution to this the default charset was ISO-8859-1 which i changed to UTF-8 and it worked with strcmp.

I think the problem was coming because of charset.

thanks anyways for your concern.

cameraman

2:09 pm on Feb 1, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Interesting - that's the first thing I thought of, but it's working on mine with ISO-8859-1 so I dismissed it.
Glad you got it worked out.