Changeset 70335
- Timestamp:
- Jan 10, 2017, 7:23:11 PM (8 years ago)
- File:
-
- 1 edited
-
grass/trunk/lib/python/script/utils.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
grass/trunk/lib/python/script/utils.py
r69811 r70335 151 151 152 152 153 def _get_encoding(): 154 encoding = locale.getdefaultlocale()[1] 155 if not encoding: 156 encoding = 'UTF-8' 157 return encoding 158 159 153 160 def decode(bytes_): 154 161 """Decode bytes with default locale and return (unicode) string … … 159 166 """ 160 167 if isinstance(bytes_, bytes): 161 enc = locale.getdefaultlocale()[1]162 return bytes_.decode(enc) if enc else bytes_.decode()168 enc = _get_encoding() 169 return bytes_.decode(enc) 163 170 return bytes_ 164 171 … … 174 181 if isinstance(string, bytes): 175 182 return string 176 enc = locale.getdefaultlocale()[1]177 return string.encode(enc) if enc else string.encode()183 enc = _get_encoding() 184 return string.encode(enc) 178 185 179 186
Note:
See TracChangeset
for help on using the changeset viewer.
