Skip to content

Commit

Permalink
Using preferred encoding instead of UTF-8
Browse files Browse the repository at this point in the history
Updates issue #2.
  • Loading branch information
phargogh committed Jun 1, 2015
1 parent 5e6fe1a commit 823e2b3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions dbfpy3/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import datetime
import struct
import sys
import locale

from . import utils

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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``."""
Expand Down

0 comments on commit 823e2b3

Please sign in to comment.