Commit 4e348784 authored by Pierre Dittgen's avatar Pierre Dittgen
Browse files

detect_encoding now test utf-8 first

parent 5fefcdf2
......@@ -14,13 +14,8 @@ def build_tabulator_params(type, name, source):
# CSV: converts to string
if format == 'csv':
scheme = 'text'
# Try UTF-8 first, then fallback to detect_encoding,
# because detection sometimes fails and returns cp1252 instead of utf-8.
try:
source = source.decode("utf-8")
except UnicodeDecodeError:
encoding = helpers.detect_encoding(source)
source = source.decode(encoding)
encoding = helpers.detect_encoding(source)
source = source.decode(encoding)
# Else use custom BytesLoader
else:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment