Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ofxparse/ofxparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ def handle_encoding(self):
cp = ascii_headers.get("CHARSET", "1252")
if cp == "8859-1":
encoding = "iso-8859-1"
elif cp == "NONE":
encoding = "1252"
else:
encoding = "cp%s" % (cp, )

Expand Down
18 changes: 18 additions & 0 deletions tests/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,24 @@ def testBrokenLineEndings(self):
ofx_file = self.OfxFileCls(fh)
self.assertEqual(len(ofx_file.headers.keys()), 2)

def testUSASCIICharsetNone(self):
fh = six.BytesIO(six.b("""OFXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:NONE
ENCODING:USASCII
CHARSET:NONE
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:NONE
"""))
ofx_file = self.OfxFileCls(fh)
headers = ofx_file.headers
result = ofx_file.fh.read()

self.assertTrue(type(result) is six.text_type)
self.assertHeadersTypes(headers)


class TestOfxPreprocessedFile(TestOfxFile):
OfxFileCls = OfxPreprocessedFile
Expand Down