Package cssutils :: Module codec |
[hide private]
[frames] | no frames]

# Module codec

source code

Python codec for CSS.

Version: $Id: util.py 1114 2008-03-05 13:22:59Z cthedot $

Author: Walter Doerwald

Classes | [hide private]
| IncrementalDecoder
| IncrementalEncoder
| StreamWriter
| StreamReader
| UTF8SigStreamWriter
| UTF8SigStreamReader

Functions | [hide private]
_detectencoding_str(input, final=False) Detect the encoding of the byte string `input`, which contains the beginning of a CSS file. | source code
_detectencoding_unicode(input, final=False) Detect the encoding of the unicode string `input`, which contains the beginning of a CSS file. | source code
_fixencoding(input, encoding, final=False) Replace the name of the encoding in the charset rule at the beginning of `input` with `encoding`. | source code
decode(input, errors=`'``strict``'`, encoding=None) | source code
encode(input, errors=`'``strict``'`, encoding=None) | source code
_bytes2int(bytes) | source code
_int2bytes(i) | source code
utf8sig_encode(input, errors='strict') | source code
utf8sig_decode(input, errors='strict') | source code
search_function(name) | source code
cssescape(exc) | source code

Imports: codecs, marshal

Function Details | [hide private]

### _detectencoding_str(input, final=False) | source code
Detect the encoding of the byte string `input`, which contains the beginning of a CSS file. To detect the encoding the first few bytes are used (or if `input` is ASCII compatible and starts with a charset rule the encoding name from the rule). If the encoding can't be detected yet, `None` is returned. `final` specifies whether more data is available in later calls or not. If `final` is true, `_detectencoding_str()` will never return `None`.

### _detectencoding_unicode(input, final=False) | source code
Detect the encoding of the unicode string `input`, which contains the beginning of a CSS file. The encoding is detected from the charset rule at the beginning of `input`. If there is no charset rule, `"utf-8"` will be returned. If the encoding can't be detected yet, `None` is returned. `final` specifies whether more data will be available in later calls or not. If `final` is true, `_detectencoding_unicode()` will never return `None`.

### _fixencoding(input, encoding, final=False) | source code
Replace the name of the encoding in the charset rule at the beginning of `input` with `encoding`. If `input` doesn't starts with a charset rule, `input` will be returned unmodified. If the encoding can't be found yet, `None` is returned. `final` specifies whether more data will be available in later calls or not. If `final` is true, `_fixencoding()` will never return `None`.