diff --git a/dbfpy3/fields.py b/dbfpy3/fields.py index 883d035..9257560 100644 --- a/dbfpy3/fields.py +++ b/dbfpy3/fields.py @@ -33,6 +33,7 @@ import datetime import struct import sys +import locale from . import utils @@ -125,7 +126,7 @@ def fromString(cls, string, start, ignoreErrors=False): """ assert len(string) == 32 _length = string[16] - return cls(utils.unzfill(string)[:11].decode('utf-8'), _length, + return cls(utils.unzfill(string)[:11].decode(locale.getpreferredencoding()), _length, string[17], start, start + _length, ignoreErrors=ignoreErrors) fromString = classmethod(fromString) @@ -209,7 +210,7 @@ def decodeValue(self, value): Return value is a ``value`` argument with stripped right spaces. """ - return value.rstrip(b' ').decode('utf-8') + return value.rstrip(b' ').decode(locale.getpreferredencoding()) def encodeValue(self, value): """Return raw data string encoded from a ``value``."""