isEncoding method Null safety

  1. @Since("2.17")
bool isEncoding(
  1. Encoding encoding
)

Whether the charset parameter represents encoding.

If the "charset" parameter is not present in the URI, it defaults to "US-ASCII", which is the ascii encoding. If present, it's converted to an Encoding using Encoding.getByName, and compared to encoding.

Implementation

@Since("2.17")
bool isEncoding(Encoding encoding) {
  var charsetIndex = _findCharsetIndex();
  if (charsetIndex < 0) {
    return identical(encoding, ascii);
  }
  var valueStart = _separatorIndices[charsetIndex + 1] + 1;
  var valueEnd = _separatorIndices[charsetIndex + 2];
  return identical(
      encoding,
      Encoding.getByName(
          _Uri._uriDecode(_text, valueStart, valueEnd, utf8, false)));
}