RE question: no I don't think `$('<div>' + x + '</div>').html() === x` should be true for every `x`.  That's why I'm decoding & encoding.

Thanks for that document... what a minefield!  OK cool, at least we agree on something (i.e. normalizing unambiguous ampersands).

I'm not sure about ambiguous ampersands though - entities.decode/encode probably handles those situations pretty well already since the JSON file seems to represent a fairly complete hash of all character references.