Function cssparser::stylesheet_encoding

source ·
pub fn stylesheet_encoding<E>(
    css: &[u8],
    protocol_encoding_label: Option<&[u8]>,
    environment_encoding: Option<E::Encoding>
) -> E::Encoding
where E: EncodingSupport,
Expand description

Determine the character encoding of a CSS stylesheet.

This is based on the presence of a BOM (Byte Order Mark), an @charset rule, and encoding meta-information.

  • css_bytes: A byte string.
  • protocol_encoding: The encoding label, if any, defined by HTTP or equivalent protocol. (e.g. via the charset parameter of the Content-Type header.)
  • environment_encoding: An optional Encoding object for the [environment encoding] (https://drafts.csswg.org/css-syntax/#environment-encoding), if any.

Returns the encoding to use.