matching words with accents, carrots, squigglies, etc.

matching words with accents, carrots, squigglies, etc.

Posted by: dambro
Posted on: 2009-07-12 10:42:00

It seems that mysql and php have different thresholds for matching a character with an accent.

Take the spanish name, "Peņa."
A query on my database like this: "SELECT * FROM `names` WHERE last = 'Pena'" still turns up Peņa, even though the two aren't exactly the same. (Thank goodness.)

Unfortunately, I can't do the same in PHP.
For example:
$name = 'Peņa';
$name2 = 'Pena';

Try testing $name == $name2 in php, and it will fail.

So my question is this:
Does anyone know of a php script that would replace characters with accents (and other types of carrots and squigglies) with their standard (boring) English counterparts?

Thanks.

Re: matching words with accents, carrots, squigglies, etc.

Posted by: vicm3
Posted on: 2009-07-12 11:41:00

I'm not an expert but as I search you need to state that your script is UTF8, I found 2 links with information, I hope that helps:

http://bugs.php.net/bug.php?id=30800 A bug report on php.net

http://www.phpwact.org/php/i18n/utf-8 UTF8 usage on php (wiki)

Tags: php scriptthresholdsaccentsgoodness