Fixed mistype in charset handling code, better diagnostics