1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 """Supports a hybrid Unicode string that knows which encoding is preferable,
23 and uses this when converting to a string."""
24
25
27
28 - def __new__(newtype, string=u"", encoding=None, errors=None):
29 if isinstance(string, unicode):
30 if errors is None:
31 newstring = unicode.__new__(newtype, string)
32 else:
33 newstring = unicode.__new__(newtype, string, errors=errors)
34 if encoding is None and isinstance(string, autoencode):
35 newstring.encoding = string.encoding
36 else:
37 newstring.encoding = encoding
38 else:
39 if errors is None and encoding is None:
40 newstring = unicode.__new__(newtype, string)
41 elif errors is None:
42 try:
43 newstring = unicode.__new__(newtype, string, encoding)
44 except LookupError, e:
45 raise ValueError(str(e))
46 elif encoding is None:
47 newstring = unicode.__new__(newtype, string, errors)
48 else:
49 newstring = unicode.__new__(newtype, string, encoding, errors)
50 newstring.encoding = encoding
51 return newstring
52
53 - def join(self, seq):
55
61