469,922 Members | 2,148 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,922 developers. It's quick & easy.

replace french characters in form input?

Our company's back end database server does not handle french
accentuated characters well. We need to replace those characters with
english letters when validating the form inputs. Any suggestions? I've
never delt with foreign languages before...any help greatly
apprieciated!
Jul 23 '05 #1
2 12110
"yearTiger2002" <ha*****@yahoo.com> wrote in message
news:66*************************@posting.google.co m...
Our company's back end database server does not handle french
accentuated characters well. We need to replace those characters with
english letters when validating the form inputs. Any suggestions? I've
never delt with foreign languages before...any help greatly
apprieciated!


It's a matter of scanning for accented character codes and replacing them
accordingly. This would be my solution, which will remove grave, acute and
circumflex accents from vowels.
<HTML>
<HEAD>
<title>Accent Stripper</title>
<STYLE>
body{font-size:1.2em}
</STYLE>
</HEAD>

<BODY bgcolor="#0000ff" text="#ffffff" link="#00ffff" vlink="#00ffff">

<FORM>
<TEXTAREA cols=30 rows=3 onblur='this.value=stripVowelAccent(this.value)' wrap>



</TEXTAREA>
</FORM>
<BR>
To strip accents, click on link or blur the text field.<BR><BR>
<A HREF='#'
onclick='document.forms[0].elements[0].value=stripVowelAccent(document.forms[0].
elements[0].value);return false'>Strip Accents</A>

<SCRIPT type='text/javascript'>

/* (C)Stephen Chalmers
* Strips grave, acute & circumflex accents from vowels
*/

function stripVowelAccent(str)
{
var s=str;

var rExps=[ /[\xC0-\xC2]/g, /[\xE0-\xE2]/g,
/[\xC8-\xCA]/g, /[\xE8-\xEB]/g,
/[\xCC-\xCE]/g, /[\xEC-\xEE]/g,
/[\xD2-\xD4]/g, /[\xF2-\xF4]/g,
/[\xD9-\xDB]/g, /[\xF9-\xFB]/g ];

var repChar=['A','a','E','e','I','i','O','o','U','u'];

for(var i=0; i<rExps.length; i++)
s=s.replace(rExps[i],repChar[i]);

return s;
}

</SCRIPT>

</BODY>
</HTML>

--
Stephen Chalmers


Jul 23 '05 #2
It works like magic, thanks a million!

I was in the middle of a painful process of creating two long arrays for
both french characters and english ones.....you saved my day!


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by darin dimitrov | last post: by
3 posts views Thread by o_swas | last post: by
8 posts views Thread by Ess355 | last post: by
5 posts views Thread by djc | last post: by
4 posts views Thread by jgabbai | last post: by
3 posts views Thread by Pascal | last post: by
reply views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.