function getInverseObj(obj) {
    return Object.keys(obj)
        .sort()
        .reduce(function (inverse, name) {
        inverse[obj[name]] = "&" + name + ";";
        return inverse;
    }, {});
}
Encodes all non-ASCII characters, as well as characters not valid in HTML
documents using HTML entities.

If a character has no equivalent entity, a
numeric hexadecimal reference (eg. `&#xfc;`) will be used.