A quick article showing my MySQL statement when I want to remove all the accents from foreign characters and return the English equivalent.
Why?
A content management system (CMS) that I'm working on has just gone international and started including the names of places in other countries. This is nice but its search engine doesn't work properly as it thinks "riviere" is different to "rivière". We need to ensure that a search for any of these kind of words will return results of similarly typed/sounding words.
How?
Here's just a splurge of SQL but I use this often enough:
html_entity_decode(htmlentities($ftext, ENT_COMPAT,'UTF-8', true), ENT_COMPAT, 'UTF-8');
- html_entity_decode(htmlentities($ftext, ENT_COMPAT,'UTF-8', true), ENT_COMPAT, 'UTF-8');
Retrieve records with foreign characters:
SELECT * FROM `myTable` WHERE `myColumn` REGEXP '[^A-Za-z0-9 -()\-.]'
Joomla! Additional
My Joomla website needed the following code to display the above foreign characters as entered into the Joomla administrators console with accents and all:
html_entity_decode(htmlentities($ftext, ENT_COMPAT,'UTF-8', true), ENT_COMPAT, 'UTF-8');