charset property

String get charset

The charset parameter of the media type.

If the parameters of the media type contains a charset parameter then this returns its value, otherwise it returns US-ASCII, which is the default charset for data URIs. If the values contain non-ASCII percent escapes, they are decoded as UTF-8.

If the MIME type representation in the URI text contains URI escapes, they are unescaped in the returned string.

Implementation

String get charset {
  var charsetIndex = _findCharsetIndex();
  if (charsetIndex >= 0) {
    var valueStart = _separatorIndices[charsetIndex + 1] + 1;
    var valueEnd = _separatorIndices[charsetIndex + 2];
    return _Uri._uriDecode(_text, valueStart, valueEnd, utf8, false);
  }
  return "US-ASCII";
}