getNames(); function getNames() { var //url = "http://unicode.org/Public/UNIDATA/NamesList.txt", url = "NamesList.txt"; $.get(url, function(data) { data = data.replace(/\n\t=/g, ""); var names = {}, json = "", split = []; $.each(data.replace(/\n/g, "\n\n").match(/\n[0-9A-F]{4}\t.+\n/g), function(i, v) { names["0x" + v.substr(1, 4)] = v.substr(6, v.length - 7); }); json = JSON.stringify(names, null, 4) $.each(data.match(/\n@@\t[0-9A-F]{4}\t.+\n/g), function(i, v) { split = v.split("\t"); split[1] = "0x" + split[1]; xx = 0 while (split[1] in names == false && xx < 10) { console.log(split[2],split[1]) split[1] = inc(split[1]); xx++; } json = json.replace("\"" + split[1], "// " + split[2] + "\n \"" + split[1]) }); json = json .replace(/ /g, "    ") .replace(/\"0x/g, "0x") .replace(/\":/g, ":") .replace(//g, ">") .replace(/\n/g, "
"); $("body").html(json); }); } function inc(str) { str = (parseInt(str, 16) + 1).toString(16).toUpperCase(); return "0x" + new Array(5 - str.length).join("0") + str; }