Convert foreign characters to English alphabet

What?
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:
copyraw
html_entity_decode(htmlentities($ftext, ENT_COMPAT,'UTF-8', true), ENT_COMPAT, 'UTF-8');
  1.  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');
Category: MySQL :: Article: 640

Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: The information on this website is provided without warranty and any content is merely the opinion of the author. Please try to test in development environments prior to adapting them to your production environments. The articles are written in good faith and, at the time of print, are working examples used in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com

Related Articles

Joes Revolver Map

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin - Valid till 8 May 2022 3QnhmaBX7LQSRsC9hh6Je9rGQKEGNQNfPb
© 2021 Joel Lipman .com. All Rights Reserved.