Reputation: 3073
I am trying to compare a value submitted as a POST to an internal string. They are both utf8 encoded. This is the code
echo $_POST["province"] . "\n";
setlocale(LC_COLLATE, "fr_CA");
echo strcoll($_POST["province"], "Québec");
This code echos the following:
Québec
-38
strcoll should return 0 if the string match, not -38. In other words, the comparison fails. How do I compare two utf8 string that are identical to a human reader, but might be encoded differently? I have tried Normalizer:normalize, the common "==" operator, looked at multibyte php extension (but there seem to be no compare functions??) and nothing worked thus far for me.
Upvotes: 0
Views: 2874
Reputation: 29985
utf8_decode
to ensure that the strings you're checking are in the same encoding.Upvotes: 5