| 1 | function replAccents(s) |
| 2 | { |
| 3 | // Replacement lists based on article in Wikipedia, |
| 4 | // http://en.wikipedia.org/wiki/Latin_Unicode |
| 5 | // from and to strings must have same number of characters |
| 6 | var from = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîï'; |
| 7 | var to = 'AAAAAAECEEEEIIIIDNOOOOOOUUUUYSaaaaaaaceeeeiiii'; |
| 8 | from += 'ñòóôõöøùúûüýÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģ'; |
| 9 | to += 'noooooouuuuyyaaaaaaccccccccddddeeeeeeeeeegggggggg'; |
| 10 | from += 'ĤĥĦħĨĩĪīĬĭĮįİıĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘř'; |
| 11 | to += 'hhhhiiiiiiiiiijjkkkllllllllllnnnnnnnnnoooooooorrrrrr'; |
| 12 | from += 'ŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƂƃƄƅƇƈƉƊƐƑƒƓƔ'; |
| 13 | to += 'ssssssssttttttuuuuuuuuuuuuwwyyyzzzzzzfbbbbbccddeffgv'; |
| 14 | from += 'ƖƗƘƙƚƝƞƟƠƤƦƫƬƭƮƯưƱƲƳƴƵƶǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩ'; |
| 15 | to += 'likklnnoopettttuuuuyyzzaaiioouuuuuuuuuueaaaaeeggggkk'; |
| 16 | from += 'ǪǫǬǭǰǴǵǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȞȟȤȥȦȧȨȩ'; |
| 17 | to += 'oooojggpnnaaeeooaaaaeeeeiiiioooorrrruuuusstthhzzaaee'; |
| 18 | from += 'ȪȫȬȭȮȯȰȱȲȳḀḁḂḃḄḅḆḇḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫ'; |
| 19 | to += 'ooooooooyyaabbbbbbccddddddddddeeeeeeeeeeffgghhhhhhhhhh'; |
| 20 | from += 'ḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟ'; |
| 21 | to += 'iiiikkkkkkllllllllmmmmmmnnnnnnnnoooooooopppprrrrrrrr'; |
| 22 | from += 'ṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋẌẍẎẏẐẑẒẓẔẕ'; |
| 23 | to += 'ssssssssssttttttttuuuuuuuuuuvvvvwwwwwwwwwwxxxxxyzzzzzz'; |
| 24 | from += 'ẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊị'; |
| 25 | to += 'htwyafaaaaaaaaaaaaaaaaaaaaaaaaeeeeeeeeeeeeeeeeiiii'; |
| 26 | from += 'ỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹ'; |
| 27 | to += 'oooooooooooooooooooooooouuuuuuuuuuuuuuyyyyyyyy'; |
| 28 | |
| 29 | for (var i = 0; i != s.length; i++) { |
| 30 | var x = from.indexOf(s[i]); |
| 31 | if (x != -1) { |
| 32 | r = new RegExp(from[x], 'g'); |
| 33 | s = s.replace(r, to[x]); |
| 34 | } |
| 35 | } |
| 36 | return s; |
| 37 | } |
| 38 | |