Package suds :: Package sax :: Module enc :: Class Encoder
[hide private]
[frames] | no frames]

Class Encoder

source code

An XML special character encoder/decoder.

Instance Methods [hide private]
boolean
needsEncoding(self, s)
Get whether string s contains special characters.
source code
str
encode(self, s)
Encode special characters found in string s.
source code
str
decode(self, s)
Decode special characters encodings found in string s.
source code
Class Variables [hide private]
[(str,str)] encodings = (('&(?!(amp|lt|gt|quot|apos);)', '&amp;'), ('<', '...
A mapping of special characters encoding.
[(str,str)] decodings = (('&lt;', '<'), ('&gt;', '>'), ('&quot;', '"'), ('...
A mapping of special characters decoding.
[char] special = ('&', '<', '>', '"', '\'')
A list of special characters
Method Details [hide private]

needsEncoding(self, s)

source code 

Get whether string s contains special characters.

Parameters:
  • s (str) - A string to check.
Returns: boolean
True if needs encoding.

encode(self, s)

source code 

Encode special characters found in string s.

Parameters:
  • s (str) - A string to encode.
Returns: str
The encoded string.

decode(self, s)

source code 

Decode special characters encodings found in string s.

Parameters:
  • s (str) - A string to decode.
Returns: str
The decoded string.

Class Variable Details [hide private]

encodings

A mapping of special characters encoding.
Type:
[(str,str)]
Value:
(('&(?!(amp|lt|gt|quot|apos);)', '&amp;'),
 ('<', '&lt;'),
 ('>', '&gt;'),
 ('"', '&quot;'),
 ('\'', '&apos;'))

decodings

A mapping of special characters decoding.
Type:
[(str,str)]
Value:
(('&lt;', '<'),
 ('&gt;', '>'),
 ('&quot;', '"'),
 ('&apos;', '\''),
 ('&amp;', '&'))