Created
March 31, 2021 18:11
-
-
Save gilbarbara/3fd2b8e88fd9ecd1388c05c02420bca5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Remove accents | |
*/ | |
export function removeAccents(input: string) { | |
const removalMap = { | |
A: /[AⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄ]/g, | |
AA: /[Ꜳ]/g, | |
AE: /[ÆǼǢ]/g, | |
AO: /[Ꜵ]/g, | |
AU: /[Ꜷ]/g, | |
AV: /[ꜸꜺ]/g, | |
AY: /[Ꜽ]/g, | |
B: /[BⒷBḂḄḆɃƂƁ]/g, | |
C: /[CⒸCĆĈĊČÇḈƇȻꜾ]/g, | |
D: /[DⒹDḊĎḌḐḒḎĐƋƊƉꝹ]/g, | |
DZ: /[DZDŽ]/g, | |
Dz: /[DzDž]/g, | |
E: /[EⒺEÈÉÊỀẾỄỂẼĒḔḖĔĖËẺĚȄȆẸỆȨḜĘḘḚƐƎ]/g, | |
F: /[FⒻFḞƑꝻ]/g, | |
G: /[GⒼGǴĜḠĞĠǦĢǤƓꞠꝽꝾ]/g, | |
H: /[HⒽHĤḢḦȞḤḨḪĦⱧⱵꞍ]/g, | |
I: /[IⒾIÌÍÎĨĪĬİÏḮỈǏȈȊỊĮḬƗ]/g, | |
J: /[JⒿJĴɈ]/g, | |
K: /[KⓀKḰǨḲĶḴƘⱩꝀꝂꝄꞢ]/g, | |
L: /[LⓁLĿĹĽḶḸĻḼḺŁȽⱢⱠꝈꝆꞀ]/g, | |
LJ: /[LJ]/g, | |
Lj: /[Lj]/g, | |
M: /[MⓂMḾṀṂⱮƜ]/g, | |
N: /[NⓃNǸŃÑṄŇṆŅṊṈȠƝꞐꞤ]/g, | |
NJ: /[NJ]/g, | |
Nj: /[Nj]/g, | |
O: /[OⓄOÒÓÔỒỐỖỔÕṌȬṎŌṐṒŎȮȰÖȪỎŐǑȌȎƠỜỚỠỞỢỌỘǪǬØǾƆƟꝊꝌ]/g, | |
OI: /[Ƣ]/g, | |
OO: /[Ꝏ]/g, | |
OU: /[Ȣ]/g, | |
P: /[PⓅPṔṖƤⱣꝐꝒꝔ]/g, | |
Q: /[QⓆQꝖꝘɊ]/g, | |
R: /[RⓇRŔṘŘȐȒṚṜŖṞɌⱤꝚꞦꞂ]/g, | |
S: /[SⓈSẞŚṤŜṠŠṦṢṨȘŞⱾꞨꞄ]/g, | |
T: /[TⓉTṪŤṬȚŢṰṮŦƬƮȾꞆ]/g, | |
TZ: /[Ꜩ]/g, | |
U: /[UⓊUÙÚÛŨṸŪṺŬÜǛǗǕǙỦŮŰǓȔȖƯỪỨỮỬỰỤṲŲṶṴɄ]/g, | |
V: /[VⓋVṼṾƲꝞɅ]/g, | |
VY: /[Ꝡ]/g, | |
W: /[WⓌWẀẂŴẆẄẈⱲ]/g, | |
X: /[XⓍXẊẌ]/g, | |
Y: /[YⓎYỲÝŶỸȲẎŸỶỴƳɎỾ]/g, | |
Z: /[ZⓏZŹẐŻŽẒẔƵȤⱿⱫꝢ]/g, | |
a: /[aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐ]/g, | |
aa: /[ꜳ]/g, | |
ae: /[æǽǣ]/g, | |
ao: /[ꜵ]/g, | |
au: /[ꜷ]/g, | |
av: /[ꜹꜻ]/g, | |
ay: /[ꜽ]/g, | |
b: /[bⓑbḃḅḇƀƃɓ]/g, | |
c: /[cⓒcćĉċčçḉƈȼꜿↄ]/g, | |
d: /[dⓓdḋďḍḑḓḏđƌɖɗꝺ]/g, | |
dz: /[dzdž]/g, | |
e: /[eⓔeèéêềếễểẽēḕḗĕėëẻěȅȇẹệȩḝęḙḛɇɛǝ]/g, | |
f: /[fⓕfḟƒꝼ]/g, | |
g: /[gⓖgǵĝḡğġǧģǥɠꞡᵹꝿ]/g, | |
h: /[hⓗhĥḣḧȟḥḩḫẖħⱨⱶɥ]/g, | |
hv: /[ƕ]/g, | |
i: /[iⓘiìíîĩīĭïḯỉǐȉȋịįḭɨı]/g, | |
j: /[jⓙjĵǰɉ]/g, | |
k: /[kⓚkḱǩḳķḵƙⱪꝁꝃꝅꞣ]/g, | |
l: /[lⓛlŀĺľḷḹļḽḻſłƚɫⱡꝉꞁꝇ]/g, | |
lj: /[lj]/g, | |
m: /[mⓜmḿṁṃɱɯ]/g, | |
n: /[nⓝnǹńñṅňṇņṋṉƞɲʼnꞑꞥ]/g, | |
nj: /[nj]/g, | |
o: /[oⓞoòóôồốỗổõṍȭṏōṑṓŏȯȱöȫỏőǒȍȏơờớỡởợọộǫǭøǿɔꝋꝍɵ]/g, | |
oi: /[ƣ]/g, | |
ou: /[ȣ]/g, | |
oo: /[ꝏ]/g, | |
p: /[pⓟpṕṗƥᵽꝑꝓꝕ]/g, | |
q: /[qⓠqɋꝗꝙ]/g, | |
r: /[rⓡrŕṙřȑȓṛṝŗṟɍɽꝛꞧꞃ]/g, | |
s: /[sⓢsßśṥŝṡšṧṣṩșşȿꞩꞅẛ]/g, | |
t: /[tⓣtṫẗťṭțţṱṯŧƭʈⱦꞇ]/g, | |
tz: /[ꜩ]/g, | |
u: /[uⓤuùúûũṹūṻŭüǜǘǖǚủůűǔȕȗưừứữửựụṳųṷṵʉ]/g, | |
v: /[vⓥvṽṿʋꝟʌ]/g, | |
vy: /[ꝡ]/g, | |
w: /[wⓦwẁẃŵẇẅẘẉⱳ]/g, | |
x: /[xⓧxẋẍ]/g, | |
y: /[yⓨyỳýŷỹȳẏÿỷẙỵƴɏỿ]/g, | |
z: /[zⓩzźẑżžẓẕƶȥɀⱬꝣ]/g, | |
}; | |
let parsedString = input; | |
Object.entries(removalMap).forEach(([key, value]) => { | |
parsedString = parsedString.replace(value, key); | |
}); | |
return parsedString; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment