replace french characters in form input?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • yearTiger2002

    #1

    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!
  • Stephen Chalmers

    #2
    Re: replace french characters in form input?

    "yearTiger2 002" <hansear@yahoo. com> wrote in message
    news:6634aaab.0 404271601.839ab c2@posting.goog le.com...[color=blue]
    > 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![/color]

    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="#0000f f" text="#ffffff" link="#00ffff" vlink="#00ffff" >

    <FORM>
    <TEXTAREA cols=30 rows=3 onblur='this.va lue=stripVowelA ccent(this.valu e)' wrap>
    À Á Â à á â È É Ê è é ê
    Ì Í Î ì í î Ò Ó Ô ò ó ô
    Ù Ú Û ù ú û
    </TEXTAREA>
    </FORM>
    <BR>
    To strip accents, click on link or blur the text field.<BR><BR>
    <A HREF='#'
    onclick='docume nt.forms[0].elements[0].value=stripVow elAccent(docume nt.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 stripVowelAccen t(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(rEx ps[i],repChar[i]);

    return s;
    }

    </SCRIPT>

    </BODY>
    </HTML>

    --
    Stephen Chalmers




    Comment

    • hansear yahoo

      #3
      Re: replace french characters in form input?

      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!

      Comment

      Working...