Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Take an ascii string and output possible unicode string equivalent in NFKD so that it is understood by IDNA within URLs
function conv_to_uni(st) {
udata = {"66":["7470","8492","9399","119809","119861","119913","120017","120069","120121","120173","120225","120277","120329","120381","120433","127281","65314"],"87":["7490","9420","119830","119882","119934","119986","120038","120090","120142","120194","120246","120298","120350","120402","120454","127302","65335"],"77":["7481","8499","8559","9410","119820","119872","119924","120028","120080","120132","120184","120236","120288","120340","120392","120444","127292","65325"],"69":["7473","8496","9402","119812","119864","119916","120020","120072","120124","120176","120228","120280","120332","120384","120436","127284","65317"],"90":["8484","8488","9423","119833","119885","119937","119989","120041","120197","120249","120301","120353","120405","120457","127305","65338"],"98":["7495","9425","119835","119887","119939","119991","120043","120095","120147","120199","120251","120303","120355","120407","120459","65346"],"117":["7512","7524","9444","119854","119906","119958","120010","120062","120114","120166","120218","120270","120322","120374","120426","120478","65365"],"81":["8474","9414","119824","119876","119928","119980","120032","120084","120188","120240","120292","120344","120396","120448","127296","65329"],"116":["7511","8348","9443","119853","119905","119957","120009","120061","120113","120165","120217","120269","120321","120373","120425","120477","65364"],"71":["7475","9404","119814","119866","119918","119970","120022","120074","120126","120178","120230","120282","120334","120386","120438","127286","65319"],"110":["8319","8345","9437","119847","119899","119951","120003","120055","120107","120159","120211","120263","120315","120367","120419","120471","65358"],"114":["691","7523","9441","119851","119903","119955","120007","120059","120111","120163","120215","120267","120319","120371","120423","120475","65362"],"111":["186","7506","8338","8500","9438","119848","119900","119952","120056","120108","120160","120212","120264","120316","120368","120420","120472","65359"],"115":["383","738","8347","9442","119852","119904","119956","120008","120060","120112","120164","120216","120268","120320","120372","120424","120476","65363"],"109":["7504","8344","8575","9436","119846","119898","119950","120002","120054","120106","120158","120210","120262","120314","120366","120418","120470","65357"],"75":["7479","8490","9408","119818","119870","119922","119974","120026","120078","120130","120182","120234","120286","120338","120390","120442","127290","65323"],"85":["7489","9418","119828","119880","119932","119984","120036","120088","120140","120192","120244","120296","120348","120400","120452","127300","65333"],"118":["7515","7525","8564","9445","119855","119907","119959","120011","120063","120115","120167","120219","120271","120323","120375","120427","120479","65366"],"112":["7510","8346","9439","119849","119901","119953","120005","120057","120109","120161","120213","120265","120317","120369","120421","120473","65360"],"99":["7580","8573","9426","119836","119888","119940","119992","120044","120096","120148","120200","120252","120304","120356","120408","120460","65347"],"68":["7472","8517","8558","9401","119811","119863","119915","119967","120019","120071","120123","120175","120227","120279","120331","120383","120435","127283","65316"],"113":["9440","119850","119902","119954","120006","120058","120110","120162","120214","120266","120318","120370","120422","120474","65361"],"119":["695","9446","119856","119908","119960","120012","120064","120116","120168","120220","120272","120324","120376","120428","120480","65367"],"105":["7522","8305","8505","8520","8560","9432","119842","119894","119946","119998","120050","120102","120154","120206","120258","120310","120362","120414","120466","65353"],"67":["8450","8493","8557","9400","119810","119862","119914","119966","120018","120174","120226","120278","120330","120382","120434","127275","127282","65315"],"86":["8548","9419","11389","119829","119881","119933","119985","120037","120089","120141","120193","120245","120297","120349","120401","120453","127301","65334"],"84":["7488","9417","119827","119879","119931","119983","120035","120087","120139","120191","120243","120295","120347","120399","120451","127299","65332"],"79":["7484","9412","119822","119874","119926","119978","120030","120082","120134","120186","120238","120290","120342","120394","120446","127294","65327"],"101":["7497","8337","8495","8519","9428","119838","119890","119942","120046","120098","120150","120202","120254","120306","120358","120410","120462","65349"],"104":["688","8341","8462","9431","119841","119945","119997","120049","120101","120153","120205","120257","120309","120361","120413","120465","65352"],"76":["7480","8466","8556","9409","119819","119871","119923","120027","120079","120131","120183","120235","120287","120339","120391","120443","127291","65324"],"74":["7478","9407","119817","119869","119921","119973","120025","120077","120129","120181","120233","120285","120337","120389","120441","127289","65322"],"89":["9422","119832","119884","119936","119988","120040","120092","120144","120196","120248","120300","120352","120404","120456","127304","65337"],"100":["7496","8518","8574","9427","119837","119889","119941","119993","120045","120097","120149","120201","120253","120305","120357","120409","120461","65348"],"122":["7611","9449","119859","119911","119963","120015","120067","120119","120171","120223","120275","120327","120379","120431","120483","65370"],"103":["7501","8458","9430","119840","119892","119944","120048","120100","120152","120204","120256","120308","120360","120412","120464","65351"],"102":["7584","9429","119839","119891","119943","119995","120047","120099","120151","120203","120255","120307","120359","120411","120463","65350"],"108":["737","8343","8467","8572","9435","119845","119897","119949","120001","120053","120105","120157","120209","120261","120313","120365","120417","120469","65356"],"120":["739","8339","8569","9447","119857","119909","119961","120013","120065","120117","120169","120221","120273","120325","120377","120429","120481","65368"],"121":["696","9448","119858","119910","119962","120014","120066","120118","120170","120222","120274","120326","120378","120430","120482","65369"],"107":["7503","8342","9434","119844","119896","119948","120000","120052","120104","120156","120208","120260","120312","120364","120416","120468","65355"],"82":["7487","8475","8476","8477","9415","119825","119877","119929","120033","120189","120241","120293","120345","120397","120449","127276","127297","65330"],"72":["7476","8459","8460","8461","9405","119815","119867","119919","120023","120179","120231","120283","120335","120387","120439","127287","65320"],"83":["9416","119826","119878","119930","119982","120034","120086","120138","120190","120242","120294","120346","120398","120450","127298","65331"],"97":["170","7491","8336","9424","119834","119886","119938","119990","120042","120094","120146","120198","120250","120302","120354","120406","120458","65345"],"78":["7482","8469","9411","119821","119873","119925","119977","120029","120081","120185","120237","120289","120341","120393","120445","127293","65326"],"70":["8497","9403","119813","119865","119917","120021","120073","120125","120177","120229","120281","120333","120385","120437","127285","65318"],"106":["690","8521","9433","11388","119843","119895","119947","119999","120051","120103","120155","120207","120259","120311","120363","120415","120467","65354"],"65":["7468","9398","119808","119860","119912","119964","120016","120068","120120","120172","120224","120276","120328","120380","120432","127280","65313"],"73":["7477","8464","8465","8544","9406","119816","119868","119920","120024","120128","120180","120232","120284","120336","120388","120440","127288","65321"],"88":["8553","9421","119831","119883","119935","119987","120039","120091","120143","120195","120247","120299","120351","120403","120455","127303","65336"],"80":["7486","8473","9413","119823","119875","119927","119979","120031","120083","120187","120239","120291","120343","120395","120447","127295","65328"]};
for (pos in st) {
cUp = st[pos].toUpperCase().charCodeAt(0);
cLo = st[pos].toLowerCase().charCodeAt(0);
for (pos_uni in udata[cUp]) {
console.log(String.fromCodePoint(udata[cUp][pos_uni]));
}
for (pos_uni in udata[cLo]) {
console.log(String.fromCodePoint(udata[cLo][pos_uni]));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.