Skip to content

Commit a65b8ef

Browse files
author
Adrian Castravete
committed
BUG: Fix handling of encoding for the StataReader pandas-dev#21244
1 parent c85ab08 commit a65b8ef

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pandas/io/stata.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
from pandas.util._decorators import deprecate_kwarg
3838

3939
VALID_ENCODINGS = ('ascii', 'us-ascii', 'latin-1', 'latin_1', 'iso-8859-1',
40-
'iso8859-1', '8859', 'cp819', 'latin', 'latin1', 'L1')
40+
'iso8859-1', '8859', 'cp819', 'latin', 'latin1', 'L1',
41+
'utf-8', 'utf8')
4142

4243
_version_error = ("Version of given Stata file is not 104, 105, 108, "
4344
"111 (Stata 7SE), 113 (Stata 8/9), 114 (Stata 10/11), "
@@ -1335,7 +1336,7 @@ def _calcsize(self, fmt):
13351336

13361337
def _decode(self, s):
13371338
s = s.partition(b"\0")[0]
1338-
return s.decode('utf-8')
1339+
return s.decode(self._encoding or self._default_encoding)
13391340

13401341
def _null_terminate(self, s):
13411342
if compat.PY3 or self._encoding is not None:

0 commit comments

Comments
 (0)