import { Buffer } from 'node:buffer'; import iconv from 'iconv-lite'; import encodingJapanese from 'encoding-japanese'; import charsets from './charsets.js'; /** * Character set encoding and decoding functions */ // Names that are decoded as UTF-8 without going through iconv-lite const UTF8_COMPATIBLE = /^(?:(?:us-)?ascii|utf-8|7bit)$/i; // iconv-lite codecs that are not character sets a message could be written in. UTF-7 is a known // way to smuggle markup past filters (=?utf-7?Q?+ADw-script+AD4-?= decodes to "