decodeAnyText static method

String decodeAnyText(
  1. String text,
  2. String? transferEncoding,
  3. String? charset
)

Implementation

static String decodeAnyText(
    String text, String? transferEncoding, String? charset) {
  transferEncoding ??= contentTransferEncodingNone;
  final decoder = _textDecodersByName[transferEncoding.toLowerCase()];
  if (decoder == null) {
    print(
        'Error: no decoder found for content-transfer-encoding [$transferEncoding].');
    return text;
  }
  charset ??= 'utf8';
  final codec = _charsetCodecsByName[charset.toLowerCase()];
  if (codec == null) {
    print('Error: no encoding found for charset [$charset].');
    return text;
  }
  return decoder(text, codec, isHeader: false);
}