Importing Text File With Diacritical Marks


B

BostonNole

Refer to MS article Q98999 for an explanation of Diacritical Marks.

When a line from a flat text file is imported from a file using the
StreamReader, any character that has a Diacritical Mark is dropped.

Sample Code:
Dim fs As FileStream
Dim sr As StreamReader

Try
fs = New FileStream("c:\temp\badrecords.txt",
FileMode.Open, FileAccess.Read)
sr = New StreamReader(fs)

Dim line As String = sr.ReadLine()
Do While Not line Is Nothing

Debug.WriteLine(line.ToCharArray())

line = sr.ReadLine()

Loop

MessageBox.Show("Done")

Catch ex As Exception
MessageBox.Show(ex.Message)
Err.Clear()

Finally
If Not sr Is Nothing Then
sr.Close()
sr = Nothing
End If
If Not fs Is Nothing Then
fs.Close()
fs = Nothing
End If

End Try
 
Ad

Advertisements

G

GhostInAK

Hello BostonNole,

Figure out what encoding scheme you are using (most likely UTF-8 or Unicode).
Then use the appropriate encoding when reading the file (your stream reader
will include and overloaded ctor which accepts an Encoding parameter).

-Boo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top