Skip to content

Commit ba3a948

Browse files
authored
Merge pull request #47 from ws-garcia/UTF8-encoding-issues
Utf8 encoding issues
2 parents 9cd0ef4 + 388c294 commit ba3a948

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/CSVTextStream.cls

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ Private Function IsValidUTF8(byteData() As Byte) As Boolean
378378
Dim i As Long
379379
Dim ANSIfile As Boolean
380380

381+
On Error GoTo err_handler
381382
i = 0
382383
ANSIfile = True
383384
While i <= UBound(byteData)
@@ -417,6 +418,9 @@ Private Function IsValidUTF8(byteData() As Byte) As Boolean
417418
End If
418419
Wend
419420
IsValidUTF8 = Not ANSIfile
421+
Exit Function
422+
err_handler:
423+
IsValidUTF8 = False
420424
End Function
421425
Private Sub NormalizeLineBreaks()
422426
Do While InStrB(1, P_TEXT, vbCrLf, vbBinaryCompare)

src/CSVinterface.cls

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ Public Function GetDataFromCSV(csvPathAndFilename As String) As String
793793
On Error GoTo ErrHandler_GetDataFromCSV
794794
FileHandled = FreeFile
795795
Open csvPathAndFilename For Binary As #FileHandled
796-
GetDataFromCSV = SPACE$(LOF(FileHandled))
796+
GetDataFromCSV = Space$(LOF(FileHandled))
797797
Get #FileHandled, , GetDataFromCSV
798798
Close #FileHandled
799799
ErrHandler_GetDataFromCSV:
@@ -3573,6 +3573,7 @@ Private Sub StreamParseCSV(configObj As CSVparserConfig, _
35733573
CSVstream.linebreakMatchingBehavior = EndLineMatchingBehavior.OnlyBackwardSense
35743574
CSVstream.unifiedLFOutput = .multiEndOfLineCSV
35753575
CSVstream.utf8EncodedFile = .utf8EncodedFile
3576+
CSVstream.autoDetectEncoding = .autoDetectEncoding
35763577
CSVstream.OpenStream .path
35773578
commToken = AscW(.commentsToken)
35783579
dynamicType = .dynamicTyping

0 commit comments

Comments
 (0)