Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Convert accented characters to standard characters

93 views
Skip to first unread message

navee

unread,
Feb 20, 2005, 6:45:58 PM2/20/05
to
Hi, I need to substitute standard characters for accented characters (French,
German, Spanish etc) before doing the comparision with the database field. for
example if the letter 'o' has an umbaut on it, I have to convert it to an 'o'
without an umlaut. How can I achieve this? I appreciate your help. Thanks.

PaulH

unread,
Feb 21, 2005, 12:06:10 PM2/21/05
to
use the replaceNoCase()function. though what happens if your database contains those chars?

navee

unread,
Feb 21, 2005, 2:07:04 PM2/21/05
to
Hi, Here is what I am trying to do. Convert accented characters to their
un-accented equivalents both in the database ?search? field, and in the web
page construcing the search query. In this way, it doesn?t matter whether the
database contains accented characters or not, or whether the user?s search
terms include accented caracters or not , all the matching is done against
un-accented equivalents.

navee

unread,
Feb 21, 2005, 1:47:41 PM2/21/05
to
Thanks for your reply. My database field also contains these characters. What I
have to do is to retrieve the database field value into a variable and convert
accented characters( German, Spanish etc character set) to standard characters
and comapre it with what I have inputted through the text box. Do I have to use
replaceNoCase() function for this? Please let me know really I am stuck here.
Thanks again.

PaulH

unread,
Feb 21, 2005, 10:15:46 PM2/21/05
to
open up your char map s/w & start going thru the accented chars. make sure you
have the char set set to "unicode" (especially if you're using mx). then just
add to the code below. i'm not that hot w/regex so you could probably make this
better.


newText=reReplaceNoCase(orgText,"?|?|?|?|?|?","a","ALL");
newText=reReplaceNoCase(newText,"?|?|?|?","e","ALL");
newText=reReplaceNoCase(newText,"?|?|?|?","i","ALL");
newText=reReplaceNoCase(newText,"?","n","ALL");
newText=reReplaceNoCase(newText,"?|?|?|?|?","o","ALL");
newText=reReplaceNoCase(newText,"?|?|?|?","u","ALL");
.
.
.
etc.......

navee

unread,
Feb 22, 2005, 11:22:17 AM2/22/05
to
Hi, Thank you very much for your help. I think it would solve my problem. Our
database field contains the name with accented characters. How would I replace
this field to match the search query? For example my database field has 'C?t?'
and my search query is looking for 'Cote'. Is it going to return any value? My
search query looks like this. 'select * from table where fname like
'%newText%'. I appreciate your help. Thanks.

PaulH

unread,
Feb 22, 2005, 12:07:06 PM2/22/05
to
maybe something like this:

<cfscript>
function deAccent(orgText) {
var newText=reReplaceNoCase(arguments.orgText,"?|?|?|?|?|?","a","ALL");


newText=reReplaceNoCase(newText,"?|?|?|?","e","ALL");
newText=reReplaceNoCase(newText,"?|?|?|?","i","ALL");
newText=reReplaceNoCase(newText,"?","n","ALL");
newText=reReplaceNoCase(newText,"?|?|?|?|?","o","ALL");
newText=reReplaceNoCase(newText,"?|?|?|?","u","ALL");

// don't forget the other chars
return newText;
}
</cfscript>

<cfquery name="search" datasource="someDSN">
SELECT *
FROM someTable
WHERE fname LIKE '%#deAccent(form.serachText)#%'.
</cfquery>

navee

unread,
Feb 22, 2005, 8:32:21 PM2/22/05
to
Hi, Thanks for your code. My database field contains the name like 'C?te' and I
inputted 'Cote' .It didn't return anything. It didn't match with database field
because accented character '?' ASCII value is different from normal 'o'. Do
you have any ideas how to comapare this text? Thanks.

PaulH

unread,
Feb 23, 2005, 1:10:44 AM2/23/05
to
that was exactly the first thing i mentioned to you. you said you had that handled.

so what exactly is the issue?

navee

unread,
Feb 23, 2005, 9:03:44 AM2/23/05
to
Sorry. You have already mentioned the database side. I am planning to modify
the search criteria to another field in my database. So I think it would solve
my problem. Thank you for all your help. Still your solution is a great help
for my task. I am using SQL server and Coldfusion 4.0. Thanks.

navee

unread,
Feb 24, 2005, 1:58:01 PM2/24/05
to
Hi, I have the name like 'St?o'. I called the function to replace the accented
character. If I use this expression it's not replacing the character.
newText=reReplaceNoCase(newText,'?,?,?,?,?','a','ALL'); But If I use single
character expression like this it's working. What's the problem with above
expression? newText=reReplaceNoCase(newText,'?','a','ALL'); Thank you very
much.

PaulH

unread,
Feb 24, 2005, 11:35:59 PM2/24/05
to
re-read my code. you're using "," instead of "|".
0 new messages