diff --git a/ofxparse/ofxparse.py b/ofxparse/ofxparse.py index 8af6c60..6b853c4 100644 --- a/ofxparse/ofxparse.py +++ b/ofxparse/ofxparse.py @@ -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, ) diff --git a/tests/test_parse.py b/tests/test_parse.py index 78bd779..7208b2b 100644 --- a/tests/test_parse.py +++ b/tests/test_parse.py @@ -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