ram
ram

Reputation: 613

javascript to replace french characters

Here the java script method what i used in my form to convert french to english

 function checkgsm(s){


        var str = s.charAt(s.length-1);
        s=s.replace(/\300/gi, "A");
        s=s.replace(/\301/gi, "A");
        s=s.replace(/\302/gi, "A");
        s=s.replace(/\303/gi, "A");
        s=s.replace(/\304/gi, "A");     
        s=s.replace(/\352/gi, "a");
        s=s.replace(/\347/gi, "C");
        s=s.replace(/\307/gi, "c");

        return s;


     }

If i entered Ç(caps) it will be changed to C(caps).Then i entered ç the result will be cc(small)..The old caps C also replaced by small c. replace method didnt care about whether it is an uppercase or lower case.If uppercase(Ç) comes it will be changed to C.If lower(ç) came it will be c.Any other method to do exact replacement ?

Upvotes: 0

Views: 631

Answers (1)

mihai
mihai

Reputation: 38563

Try without the i mode on the regex.

s=s.replace(/\307/g, "c");

Upvotes: 1

Related Questions