@@ -169,23 +169,26 @@ def decode(text, default_codec=None):
169
169
try :
170
170
if text .startswith (BOM_UTF8 ):
171
171
# UTF-8 with BOM
172
- return str (text [len (BOM_UTF8 ):] ), ' utf-8-bom'
172
+ return str (text [len (BOM_UTF8 ) :], "utf-8" ), " utf-8-bom"
173
173
elif text .startswith (BOM_UTF16 ):
174
174
# UTF-16 with BOM
175
- return str (text [len (BOM_UTF16 ):] ), ' utf-16'
175
+ return str (text [len (BOM_UTF16 ) :], "utf-16" ), " utf-16"
176
176
elif text .startswith (BOM_UTF32 ):
177
177
# UTF-32 with BOM
178
- return str (text [len (BOM_UTF32 ):]), 'utf-32'
178
+ return str (text [len (BOM_UTF32 ) :], "utf-32" ), "utf-32"
179
+
179
180
coding = get_coding (text , default_codec = default_codec )
180
181
if coding :
181
182
return str (text , coding ), coding
182
183
except (UnicodeError , LookupError ):
183
184
pass
185
+
184
186
# Assume UTF-8
185
187
try :
186
- return str (text ), ' utf-8-guessed'
188
+ return str (text , "utf-8" ), " utf-8-guessed"
187
189
except (UnicodeError , LookupError ):
188
190
pass
191
+
189
192
# Assume Latin-1 (behaviour before 3.7.1)
190
193
return str (text , "latin-1" ), 'latin-1-guessed'
191
194
0 commit comments