Changeset 135 for pyyaml/trunk/lib/yaml/representer.py
- Timestamp:
- 04/12/06 18:26:41 (7 years ago)
- File:
-
- 1 edited
-
pyyaml/trunk/lib/yaml/representer.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
pyyaml/trunk/lib/yaml/representer.py
r133 r135 120 120 121 121 def represent_str(self, native): 122 encoding = None 122 123 try: 123 native.encode('ascii') 124 ascii = True 125 except (UnicodeDecodeError, UnicodeEncodeError): 126 ascii = False 127 if ascii: 124 unicode(native, 'ascii') 125 encoding = 'ascii' 126 except UnicodeDecodeError: 127 try: 128 unicode(native, 'utf-8') 129 encoding = 'utf-8' 130 except UnicodeDecodeError: 131 pass 132 if encoding: 128 133 return self.represent_scalar(u'tag:yaml.org,2002:str', 129 unicode(native, 'ascii'))134 unicode(native, encoding)) 130 135 else: 131 136 return self.represent_scalar(u'tag:yaml.org,2002:binary',
Note: See TracChangeset
for help on using the changeset viewer.
