Remove Vietnamese Accented Character using Javascript
May 11th, 2011 by Administrator    

This is a script that removes Vietnamese accented characters from a string. This script can also be used to remove other languages accented characters.

function str_replace(search, replace, str)
{
var ra = replace instanceof Array, sa = str instanceof Array, l = (search = [].concat(search)).length, replace = [].concat(replace), i = (str = [].concat(str)).length;
while(j = 0, i–)
while(str[i] = str[i].split(search[j]).join(ra ? replace[j] || “” : replace[0]), ++j < l);
return sa ? str : str[0];
}
function remove_accents(str)
{
accents_arr= new Array(
“à”,”á”,”ạ”,”ả”,”ã”,”â”,”ầ”,”ấ”,”ậ”,”ẩ”,”ẫ”,”ă”,
“ằ”,”ắ”,”ặ”,”ẳ”,”ẵ”,”è”,”é”,”ẹ”,”ẻ”,”ẽ”,”ê”,”ề”,
“ế”,”ệ”,”ể”,”ễ”,
“ì”,”í”,”ị”,”ỉ”,”ĩ”,
“ò”,”ó”,”ọ”,”ỏ”,”õ”,”ô”,”ồ”,”ố”,”ộ”,”ổ”,”ỗ”,”ơ”,
“ờ”,”ớ”,”ợ”,”ở”,”ỡ”,
“ù”,”ú”,”ụ”,”ủ”,”ũ”,”ư”,”ừ”,”ứ”,”ự”,”ử”,”ữ”,
“ỳ”,”ý”,”ỵ”,”ỷ”,”ỹ”,
“đ”,
“À”,”Á”,”Ạ”,”Ả”,”Ô,””,”Ầ”,”Ấ”,”Ậ”,”Ẩ”,”Ẫ”,”Ă”,
“Ằ”,”Ắ”,”Ặ”,”Ẳ”,”Ẵ”,
“È”,”É”,”Ẹ”,”Ẻ”,”Ẽ”,”Ê”,”Ề”,”Ế”,”Ệ”,”Ể”,”Ễ”,
“Ì”,”Í”,”Ị”,”Ỉ”,”Ĩ”,
“Ò”,”Ó”,”Ọ”,”Ỏ”,”Õ”,”Ô”,”Ồ”,”Ố”,”Ộ”,”Ổ”,”Ỗ”,”Ơ”,
“Ờ”,”Ớ”,”Ợ”,”Ở”,”Ỡ”,
“Ù”,”Ú”,”Ụ”,”Ủ”,”Ũ”,”Ư”,”Ừ”,”Ứ”,”Ự”,”Ử”,”Ữ”,
“Ỳ”,”Ý”,”Ỵ”,”Ỷ”,”Ỹ”,
“Đ”
);
no_accents_arr= new Array(
“a”,”a”,”a”,”a”,”a”,”a”,”a”,”a”,”a”,”a”,”a”,
“a”,”a”,”a”,”a”,”a”,”a”,
“e”,”e”,”e”,”e”,”e”,”e”,”e”,”e”,”e”,”e”,”e”,
“i”,”i”,”i”,”i”,”i”,
“o”,”o”,”o”,”o”,”o”,”o”,”o”,”o”,”o”,”o”,”o”,”o”,
“o”,”o”,”o”,”o”,”o”,
“u”,”u”,”u”,”u”,”u”,”u”,”u”,”u”,”u”,”u”,”u”,
“y”,”y”,”y”,”y”,”y”,
“d”,
“A”,”A”,”A”,”A”,”A”,”A”,”A”,”A”,”A”,”A”,”A”,”A”,
“A”,”A”,”A”,”A”,”A”,
“E”,”E”,”E”,”E”,”E”,”E”,”E”,”E”,”E”,”E”,”E”,
“I”,”I”,”I”,”I”,”I”,
“O”,”O”,”O”,”O”,”O”,”O”,”O”,”O”,”O”,”O”,”O”,”O”,
“O”,”O”,”O”,”O”,”O”,
“U”,”U”,”U”,”U”,”U”,”U”,”U”,”U”,”U”,”U”,”U”,
“Y”,”Y”,”Y”,”Y”,”Y”,
“D”
);
return str_replace(accents_arr,no_accents_arr,str);
}

You might also be interested in:

10 Comments

  1. Ugg boots at http://www.uggonly.com people used to call snow brand UGG.

  2. Different style will make you fashion, noble and elegant. Our websites http://www.hotpinkuggs.com have everything that you expect to find.Ugg kensington,ugg bailey button triplet,ugg classic cardy,ugg classic tall,and ugg australia boots lead you to a fashion trend.

  3. If you’d like to know more about our fantastic operating systems about QuickBooks,Office 2010 and Office 2007,please click here http://www.microsoft-windows-7.org/ We believe that you’ll never been so satisfied.

  4. Mulberry Handbags tends to be liked by more and more people, Mulberry Outlet can accompany with you to attend various parties, like Mulberry Bayswater Bags are most known, as well as Mulberry Alexa Bags. Due to the perfect extending and outstanding performance, chic Mulberry Messenger Bags is also popular. and people who like this feminine style also fond of the Mulberry Hobo Bags, couple with Mulberry Clutch Bags. In your busy-working life, you can also take Mulberry Shoulder Bags, so convinient and easygoing with your clothes. and you can also experience the Mulberry Satchel to enjoy the different fresh feeling. Or maybe you would also give a gift to your beloved, Mulberry Roxanne Bags would be advised to you, if not enough, you can also take Mulberry Wallets into consideration, so fine quality and fine craftmanship for every gentleman. Different styles and colors are available in Mulberry Factory Shop now, it can satisfy your various requirments, now it’s your time to own the Cheap Mulberry Handbagsï¼�style yourself up wherever you go from http://www.mulberryhandbags-factory.com. Here we’d like to share another excellent heels with you. Brand-new Nike Heels is the perfect extension of Nike Shoes, you can fully show your beautiful curve with the Nike Dunk Heels, for example, you can wear Nike Dunk SB Low Heels for the outdoor life, or you can share a pair of Nike Dunk SB High Heels with your friends, we can say that Cheap Nike Heels can be a good addition to any closet. As jordan fans, you can consider about Air Jordan 1 High Heels, far beyongd your imagination, couple with Air Jordan 4 High Heels, fit for every lady, and you will find it hard to refuse the Air Jordan 5 High Heels glamour, full of enthusiation and Air Jordan 7 High Heels can be thought as the item that always give people pleasant day.People from all zones can buy your Air Jordan 8 High Heels, make your day more wonderful, It’s said that Air Jordan 11 High Heels are the breakthrough in the history of Nike, wait for your verify. And the powerful Air Jordan 12 High Heels perfully combines the Nike soul into its design, make you love walking than before. Besides, Air Jordan 13 High Heels bring a cozy feeling to your feet, easygoing with your casual wearing. and Air Jordan 23 High Heels chanllengs the aesthetic pinnacle, make your busy day full of admiration and attention, you can compare it with Roger Vivier Shoes , unexpected surprise survives at Nike Sandals Women as well.When it comes to which style can accompany with you for the party, more and more young people are apt to buy Air Jordan Heels, of course, more choice, such as Roger Vivier. In summary, http://www.nikedunkheelsbuy.com/ can satisfy all your needs, come on!

  5. With our development of economy,more and more people pay attention to wear health and comfort products.So the ugg boots have become the best choice.Ugg
    at http://www.ugg-au.info is worldwide generally known as among the finest producers that generate high-quality,stylish and comfortable products.

  6. Online Article……

    [...]The information mentioned in the article are some of the best available [...]……

  7. There is no doubt that ugg is becoming the new hot topic among the fashion people.Most people,at their first sight,can not understand why such a pair of ugly boots with such a hulking figure could be so popular.That is where it is legendary.It is such a kind of ugg boots that causes a global craze sweeping the whole world.However,what we can not deny is that once you wear is certain boot,you are absolutely unwilling to take off it,for its originality,credibility,and most of all:its incomparable comfortableness. Different style will make you fashion, noble and elegant. Our websites http://www.hotpinkuggs.com have everything that you expect to find.Ugg kensington,ugg bailey button triplet,ugg classic cardy,ugg classic tall,and ugg australia boots lead you to a fashion trend.

Share your thought:

 
Web design by Phong Vu - All content posted on here is copyright by Phong Vu and its rightful owner.