Utility for mapping content-types to charsets

This turns out to actually be more complicated than "if it exists,
use it, otherwise latin-1".  The relevant standards are somewhat
contradictory, but especially for JSON this is important.