detectHeaderEncoding static method

HeaderEncoding detectHeaderEncoding(
  1. String value
)

Detects the encoding used in the given header value.

Implementation

static HeaderEncoding detectHeaderEncoding(String value) {
  final match = _headerEncodingExpression.firstMatch(value);
  if (match == null) {
    return HeaderEncoding.none;
  }
  final group = match.group(0);

  return group?.contains('?B?') ?? group?.contains('?b?') ?? false
      ? HeaderEncoding.B
      : HeaderEncoding.Q;
}