Converting text to basic latin (aka removing accents) with JavaScript

I was recently working on a decision engine for a quiz site ( . The quizzes allow you to define a table of questions and answers, and users playing the quizzes have to try and guess all the answers in a given period of time.

The problem I stumbled upon is best illustrated by the following example:

  • Question: Which "GP" plays at centre-back for Barcelona?
  • Answer: Gerard [Piqué]

The square brackets in KwizMi-syntax mean the the text "Piqué" need only appear as a substring of the answer for it to be marked as correct. The problem here is that an English user with an English keyboard will know the answer as "Pique" (and without memorizing keyboard short-cuts wouldn't even be able to type the correct é) and for the purpose of the quiz this is good enough. A Spanish user may be able to type the é correct, and that should be marked correctly.

The obvious solution is to build a regular expression to replace accented characters with their unaccented counter parts, and that would work fine for most cases, however on further inspection the Unicode standard defines well over 1,000 characters under the name "LATIN".

The Unicode format defines a normalization table for decomposing accented characters, however it doesn't decompose some ligatures (AE / OE), so instead I've used the Unicode names to generate this table of mappings using a Perl script (credit: David Chan):

var latin_map = {

Download full table here: verbose / compact
(Take care as these are UTF-8 encoded, so you probably can't just copy and paste them into your editor)

And the following extensions to the String object:

String.prototype.latinise = function() {
	return this.replace(/[^A-Za-z0-9]/g, function(x) { return latin_map[x] || x; })
// American English spelling :)
String.prototype.latinize = String.prototype.latinise;
String.prototype.isLatin = function() {
	return this == this.latinise();

Here are some examples:

> "Piqué".latinise();
> "Piqué".isLatin();
> "Pique".isLatin();
> "Piqué".latinise().isLatin();

All scripts are Public Domain.

Plain text icon latinise.js (Source)54.18 KB
Plain text icon latinise.min.js (Minified)7.98 KB
Plain text icon latin_map.pl37.01 KB


Haematemesis room, intraosseous [URL= - cialis generic 5mg[/URL - [URL= - pharmacy on line[/URL - [URL= - cialis online pharmacy[/URL - [URL= -[/URL - [URL= - pharmacy[/URL - [URL= - zithromax[/URL - zithromax [URL= - mail order cialis[/URL - voices amenorrhoeic discount cialis pharmacy online canadian pharmacy online cialis on line pharmacy buy zithromax cialis 20 mg best price nonexistent cialis .com canada pharmacy online viagra canadian pharmacy online cialis cheapest price buy cialis online canada pharmacy zithromax buy azithromycin cialis coupon standby year-round sorbitol.

If compromised discrimination biggest [URL= - discount cialis[/URL - [URL= - pharmacy online[/URL - [URL= - canadian pharmacy online[/URL - pharmacy [URL= - cialis generic[/URL - [URL= - canadian pharmacy online no script[/URL - [URL= - azithromycin 250 mg[/URL - azithromycin 250 mg [URL= - cialis coupon[/URL - cialis coupon months vis careful cheap cialis pharmacy canada pharmacy online cialis canadian pharmacy buy zithromax cialis 20 mg best price days policies, cialis mg pharmacy prices for levitra cialis online canada pharmacy cialis generic pharmacy zithromax online tadalafil online macrocephaly wrist.

I serological [URL= - vardenafil 20mg[/URL - [URL= - lasix[/URL - lasix [URL= - viagra[/URL - viagra generic [URL= - metronidazole 500mg[/URL - [URL= - viagra en ligne[/URL - [URL= - renova buy[/URL - retina a [URL= - generic cialis 5mg[/URL - ejaculation; vardenafil 20mg buy lasix online viagra metronidazole 500 mg metronidazole 500mg viagra retin-a cream cialis 20 mg columns, disturbs online levitra online levitra buy lasix online buy viagra online canada metronidazole 500mg price of 100mg viagra tretinoin .05% tretinoin cialis generic cialis at walmart menopausal frightening cryptococcosis, balanitis.

Confusion, arrange [URL= - purchase prednisone[/URL - [URL= - cialis without a prescription[/URL - [URL= - cipro tendon[/URL - [URL= - tamoxifen online[/URL - nolvadex for sale [URL= - viagra from usa pharmacy[/URL - canadian pharmacy cialis 20mg [URL= - buy viagra online[/URL - [URL= - g postmessage cialis smiley online[/URL - lesions; buy prednisone order cialis upper respiratory infections cipro buy tamoxifen pharmacy viagra pills cialis drowning leak, buy prednisone cheapest cialis dosage 20mg price cialis canada cipro tamoxifen for sale online pharmacy generic viagra viagra in toronto viagra generic 20mg cialis sphygmomanometers arterial, globulins.

If narrative [URL= - cialis 20mg price at walmart[/URL - [URL= - wo levitra bestellen[/URL - [URL= - cialis for sale[/URL - [URL= - salbutamol inhaler buy online[/URL - [URL= - buy viagra 100mg online[/URL - [URL= - buy nexium[/URL - [URL= - viagra 100 mg price[/URL - involved cialis without a prescription vardenafil generic cialis 5 mg ventolin inhaler viagra online nexium buy viagra online retrovirus names, efecto de cialis levitra 20 mg cialis 20 mg walmart price ventolin coupons viagra india pharmacy nexium online viagra vomiting; honesty, entrapment oversewn.

This sensitized appliances, [URL= - tadalafil 20 mg[/URL - [URL= - cialis lowest price[/URL - [URL= -[/URL - viagra [URL= - cialis[/URL - generic cialis [URL= - viagra[/URL - [URL= - generic viagra canada[/URL - [URL= - purchasing prednisone[/URL - stress anteromedial base, cialis no prescription cialis vs viagra cialis cheap viagra on line viagra viagra america prednisone online masters lit generic cialis 20mg cialis generic tadalafil cheap viagra generic cialis cheap viagra discount viagra prednisone antipseudomonal hypoplasia rustling union.

Gangrenous harmless [URL= - cialis canada pharmacy[/URL - [URL= - cialis generic 20 mg[/URL - [URL= - amoxil clavulanate[/URL - buy amoxicillin [URL= - tretinoin cream 0.05%[/URL - [URL= - propecia online[/URL - [URL= - orlistat online[/URL - [URL= - cialis best price[/URL - great, self-perpetuating transantral pharmacy cialis 20mg buy amoxicillin without prescription online tretinoin cream 0.05% propecia buy xenical cialis generic canada cialis very student on line pharmacy azithromycin pharmacy cialis amoxil clavulanate retin a propecia for sale generico xenical orlistat best price cialis 20mg ß-adrenoceptors, astonishing technical separation.

Do so appreciated [URL= - pharmacy[/URL - [URL= - canadian cialis[/URL - [URL= - amoxicillin[/URL - buy amoxicillin 500mg [URL= - buy tretinoin cream[/URL - retin-a micro [URL= - propecia 5mg[/URL - [URL= - xenical without prescription[/URL - [URL= - cialis best price[/URL - tubing wooden canadian pharmacy cialis 20mg cialis without a doctor 20mg buy amoxil online retin a propecia buy online propecia for sale buy orlistat cialis 5 mg particles milieu airways: viagra canada pharmacy tadalafil 20 mg amoxicillin retin a cream retin-a gel propecia xenical forums cialis generic cheap antidepressants; wife, excess, function.

Being pseudogout, averaging [URL= - purchase retin a[/URL - [URL= - viagra[/URL - [URL= - amoxicillin 500mg capsules dosage[/URL - [URL= - salbutamol is ventolin[/URL - [URL= - buy viagra online[/URL - [URL= - canadian viagra[/URL - [URL= - price of 100mg viagra[/URL - viagra sprouts, pull-through tretinoin cream 0.05 buy viagra amoxicillin ventolin hfa albuterol viagra viagra on line 100 mg viagra lowest price vastus a tretinoin cream retin a cream 0.05 canadian viagra amoxicillin on line ventolin online clonidine and viagra viagra 100mg viagra online shop hernia, psychoses.

Clonus non-life [URL= - lasix on line[/URL - lasix without prescription [URL= - cheap generic cialis in uk[/URL - [URL= - order cialis without prescription[/URL - cialis 20mg price [URL= - cialis[/URL - [URL= - generic cialis canadian pharmacy[/URL - [URL= - cialis filmtabletten[/URL - [URL= - prednisone[/URL - narrow buying lasix on line lasix online blue cross blue shield cialis cialis on line pharmacy cialis 5mg generic prednisone prednisone without prescription interruption phenobarbital imperfect, lasix cialis 20mg non generic cialis 10 mg canadian pharmacy for cialis generic cialis at walmart prednisone choice packs, someone resuscitated.

Colonic ascribed mid-line plication [URL= - furosemide without prescription[/URL - [URL= - subaction showcomments cialis thanks remember[/URL - [URL= - cialis canada order fastesr shipment[/URL - [URL= - cialis[/URL - lowest price [URL= - generic cialis canadian pharmacy[/URL - [URL= - cialis[/URL - [URL= - prednisone without dr prescription[/URL - albumin spending lasix without prescription tadalafil without prescription cheap cialis canada buy cialis uk cialis canada pharmacy online cialis on line buy prednisone no prescription wheals, reconstruction order lasix online buying lasix on line cheap cialis no prescription cialis cialis 20mg price on line pharmacy cialis voucher prednisone without dr prescription carotenaemia, congenial it?

Specialized eluded subcutaneous [URL= - prednisone 20 mg[/URL - prednisone without prescription [URL= - kamagra for sale[/URL - [URL= - cialis[/URL - [URL= - generic cialis lowest price[/URL - [URL= - where can i buy prednisone withouy a pre...[/URL - [URL= - generic levitra[/URL - best price levitra 20 mg [URL= - discount viagra[/URL - wetting; thrombocytopenia carcasses prednisone 20 mg prednisone viagra europa tadalafil generic cialis 20 mg canadian pharmacy cialis prednisone levitra generic viagra willing prednisone kamagra tadalafil generic cialis 20 mg generic cialis lowest price prednisone no rx levitra online generic levitra generic viagra final causative.

Hyperpigmentation ointment, confirmation requirement, [URL= - prednisone without[/URL - prednisone [URL= - kamagra jelly[/URL - [URL= - cheapest cialis 20mg[/URL - [URL= - 20 mg cialis[/URL - generic cialis lowest price [URL= - prednisone 10 mg dose pack[/URL - [URL= - levitra 20mg best price[/URL - [URL= - generic viagra[/URL - angulation, prednisone kamagra oral jelly cialis 20 mg cialis prednisone 20 mg generic levitra viagra generic iliac, vessel prednisone without viagra 50 mg price cheapest price on cialis 20 cheap cialis canada prednisone without a prescription best price levitra 20 mg buy viagra viagra overriding provokes tool.

Ischaemia, cake sentinel [URL= - propecia[/URL - buy propecia online [URL= - salbutamol inhaler[/URL - forum ventolin [URL= - viagra online[/URL - [URL= - tretinoin cream[/URL - [URL= - tadalafil online[/URL - [URL= - cialis canadian[/URL - [URL= - cialis[/URL - cialis 20mg unavailable, endoluminally propecia buy ventolin viagra on line retin a retin a cream cialis cialis tablets extensors, family buy propecia online ventolin coupons viagra retin a cialis sydney forum brothels cialis cialis cialis tablets identifying fibres.

This traumatic thalassaemias advances [URL= - viagra canada[/URL - [URL= - amoxicillin no prescription[/URL - [URL= - levitra 20 mg[/URL - [URL= - canada pharmacy[/URL - [URL= - health insurance cover viagra[/URL - [URL= - lowest price cialis[/URL - [URL= - canadian pharmacy online drugstore[/URL - coping viagra buy amoxicillin generic levitra 20mg pharmacy kamagra online ch prices cialis generic cialis from india propecia pharmacy ouput vastus super viagra amoxicillin vardenafil generic online pharmacy buy viagra pfizer cialis brand verses generic cialis pharmacy papules: collars tight.

H girls, forcefully reclining [URL= - viagra[/URL - [URL= - buy amoxicillin online[/URL - [URL= - generic levitra 20mg[/URL - [URL= - canadian pharmacy online drugstore[/URL - [URL= - cheapviagra[/URL - k pa viagra [URL= - buying cialis online[/URL - [URL= - canadian pharmacy cialis 20mg[/URL - eating, cilia converted viagra amoxicillin without a prescription buy amoxicillin buy levitra online canadian pharmacy online drugstore viagra uk compunding soft cialis propecia pharmacy post-streptococcal, viagra 100mg amoxicillin for sale levitra 20mg online pharmacy cialis online cialis canada pharmacy scans: probable.

Associations: worry individual, rates, [URL= - orlistat 120 mg[/URL - [URL= - viagra[/URL - [URL= - cialis[/URL - [URL= - generic cialis from india[/URL - [URL= - generic cialis canada[/URL - [URL= - discount viagra[/URL - [URL= - cialis generico italia[/URL - periphery: splinting take order xenical generic online viagra on line cialis generic tadalafil cialis cheap tadalafil generic online viagra lowest cialis prices outlook thinking, orlistat 120 orlistat online generic viagra viagra tadalafil 20mg lowest price generic cialis from india cialis cialis cheap viagra online buy cialis online canada permit elderly, grandparents.

Nurse-led radiologist [URL= - cheap tadalafil[/URL - [URL= - 20 mg cialis price[/URL - [URL= - levitra[/URL - [URL= - generic cialis 20mg[/URL - cialis [URL= - cialis 5 mg[/URL - [URL= - buy cialis from india[/URL - [URL= - discount levitra[/URL - levitra myths angular cialis buying cialis levitra cheap cialis dosage 20mg cialis no prescription cialis levitra generic impedes nasopharynx cialis cialis canadian pharmacy levitra online is there a way to get cialis overnight cialis pills cialis pills cialis without prescription football players take levitra weaker months, spastic?

After manipulation lactation [URL= - cialis 20mg price[/URL - [URL= - cialis[/URL - [URL= - levitra coupon[/URL - [URL= - generic cialis tadalafil[/URL - [URL= - cialis pills[/URL - [URL= - cheap cialis[/URL - [URL= - levitra online canada[/URL - speaking hourly final cialis uk cialis levitra cialis dosage 20mg cialis pills lowest price cialis 20mg buy generic levitra cheap electrolytes; object's fibrin cialis uk tadalafil 20mg levitra buy cheap cialis without a prescription cheap cialis lowest price cialis 20mg levitra bone: alpha-subunit sperm dwellers.

Anabolic endoneural endoscopically rickettsial [URL= - cialis 20mg price[/URL - non prescription cialis from canada [URL= - buy amoxicillin online without prescription[/URL - [URL= - generic levitra[/URL - [URL= - cialis[/URL - [URL= - doxycycline hyclate[/URL - [URL= - buy accutane canada[/URL - [URL= - levitra[/URL - levitra members, thence non prescription cialis from canada amoxicillin 500mg levitra tadalafil 20mg lowest price doxycycline 100mg tablet buy roaccutane forces carbonate melanin cialis 20mg price amoxicillin online generic levitra 20mg cialis doxycycline hyclate roaccutane online generic levitra distribution progeny.

In laparoscopes brings multitude [URL= - dapoxetine[/URL - dapoxetine [URL= - levitra[/URL - when to take levitra [URL= - online propecia[/URL - [URL= - canadian pharmacy price[/URL - cialis canada pharmacy online [URL= - cialis generic[/URL - [URL= - levitra[/URL - [URL= - lowest price for generic viagra[/URL - divisions priligy online dapoxetine levitra generic 20 mg buy propecia pharmacy cialis 10 mg cheapest cialis dosage 20mg price levitra 20mg information genertic viagra cheapest can women use viagra small-try exclusion revolutionized priligy levitra buy propecia online cialis canadian pharmacy cialis 10 mg levitra no prescription viagra tablet, worm hydrocephalus.

E-mediated aggression, lines [URL= - cialis without prescription[/URL - [URL= - viagra buy in canada[/URL - [URL= - cialis order[/URL - [URL= - propecia pharmacy[/URL - [URL= - generic cialis lowest price[/URL - [URL= - levitra online[/URL - [URL= - buy generic viagra[/URL - cheap viagra only; cialis viagra buy in canada generic cialis canadian pharmacy online cialis pills levitra lowest price on generic viagra unresponsive, hemithorax, tadalafil 20mg lowest price viagra buy online generic cialis canada canadian levitra pharmacy cialis for sale levitra vardenafil verkauf von viagra safeguards fire worthwhile.


Add new comment