*Get an encoding* and *decode* are defined in the Encoding Standard: http://encoding.spec.whatwg.org/#concept-encoding-get http://encoding.spec.whatwg.org/#decode Determining the encoding of a style sheet and then decoding it: 1. Let encoding be utf-8. 2. If HTTP or equivalent protocol defines an encoding (e.g. via the charset parameter of the Content-Type header), *get an encoding* for the specified value. If that does not return failure, set encoding to the return value and jump to the last step. 3. Check the byte stream. If the first set of bytes matches 40 63 68 61 72 73 65 74 20 22 (XX)* 22 3B then *get an encoding* for the sequence of XX bytes, decoded per windows-1252, and let temp be the return value. Note: Anything ASCII-compatible will do, so using windows-1252 is fine. If temp is utf-16 or utf-16be, set temp to utf-8. If temp is not failure, set encoding to the return value and jump to the last step. Note: This mimics HTML behavior. 4. *Get an encoding* for the value of the charset attribute on the element or processing instruction that caused the style sheet to be included, if any, and if that does not return failure, set encoding to the return value and jump to the last step. 5. Set encoding to the encoding of the referring style sheet or document, if any. 6. *Decode* the byte stream using fallback encoding encoding. Note: The *decode* algorithm lets the byte order mark (BOM) take precedence, hence the usage of "fallback" above. Note to specification editors: Step 4/5 should probably be an input to this algorithm from the specifications that define importing style sheets. That would be much cleaner. Acknowledgments: Henri Sivonen, Simon Pieters