How to achieve "accent-insensitive" searching
Steve Hay <[email protected]>
| Newsgroups | gmane.comp.db.mysql.perl |
|---|---|
| Message-ID | <[email protected]> |
You'd heard of case-insensitive searching. What about "accent-insensitive" searching? I want to store text containing accented characters in the database (in tables with UTF-8 charset), but allow users to search (via a perl-backed web front-end) using both the accented characters and their corresponding unaccented characters where there are obvious correspondences. For example, I want to be able to store "José", but allow users to find that by searching for either "José" or "Jose". At the moment, all I can come up with is storing two columns in the table -- one holding the accented charcaters, and one holding the corresponding ASCII equivalent where possible. So when somebody enters "José" into the database, "José" gets stored in a "name" column and "Jose" gets stored in a "asciiname" column. Then, when users do a search, their search criteria is ASCII-ized by the same routine that produced the data to insert into the "asciiname" column and then a SQL query along the lines of "SELECT ... FROM name, ... WHERE asciiname LIKE <ascii-ized search criteria>" can be performed. Is there any better way to achieve this? In particular, does the database have the means to do this kind of thing itself, rather than having to do it in the perl code? - Steve ------------------------------------------------ Radan Computational Ltd. The information contained in this message and any files transmitted with it are confidential and intended for the addressee(s) only. If you have received this message in error or there are any problems, please notify the sender immediately. The unauthorized use, disclosure, copying or alteration of this message is strictly forbidden. Note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Radan Computational Ltd. The recipient(s) of this message should check it and any attached files for viruses: Radan Computational will accept no liability for any damage caused by any virus transmitted by this email.