Last active
August 29, 2015 14:16
-
-
Save tehsis/96e03c1c688239f0ca50 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
// Gets charachter map from http://unicode.org/charts/charindex.html | |
var fs = require('fs'); | |
var request = require('superagent'); | |
var cheerio = require('cheerio'); | |
var map = {}; | |
request.get('http://unicode.org/charts/charindex.html') | |
.end(function(res) { | |
var $ = cheerio.load(res.text); | |
$('a[href*=pdf]').each(function() { | |
var code = String.fromCharCode(parseInt($(this).text(), 16)); | |
var character_title = $(this).parent().prev().text(); | |
var character = character_title.charAt(0); | |
if(character_title.charAt(1) === ' ' || character_title.charAt(1) === ',') { | |
map[code] = character; | |
} | |
}); | |
fs.writeFile('../charMap.json', JSON.stringify(map), function (err) { | |
if (err) return console.log(err); | |
console.log('charMap.json created!'); | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment