Wedge
07-30-2007, 06:32 PM
From TextFile into a RichTextBox, how can you make it (or if it's the
streamreader thingy that is to blame?) recognize ANSI text? My
foreign characters å, ä, and ö are missing from the text.
Scenario:
I type some text in Notepad. Save the text to disk, using the ANSI
character encoding setting in Notepad's Save as dialog box. Presto,
å, ä, and ö are missing from the text when I open it in a simple
RichEditBox on a form.
If I on the other hand save the text using UTF-8 encoding in Notepad,
I can open the text in the RichTextBox and the characters I'm after
are intact.
Here's the code I use to read the text (found on-line):
[imports excluded!]
If File.Exists(sFileName) Then
Dim TextFileStream As TextReader
TextFileStream = File.OpenText(sFileName)
edtEditor.Text = TextFileStream.ReadToEnd
TextFileStream.Close()
End If
Here's the code I use to write the text (parts of it found on-line):
[imports excluded!]
Private Sub SaveIt(ByRef what As String, ByVal where As String)
Dim fileWriter As New StreamWriter(where)
fileWriter.WriteLine(what)
fileWriter.Close()
End Sub
TIA for any suggestions.
Oh, and I use this VB .NET 2005 Express Edition, if it matters.
--
Wedge
streamreader thingy that is to blame?) recognize ANSI text? My
foreign characters å, ä, and ö are missing from the text.
Scenario:
I type some text in Notepad. Save the text to disk, using the ANSI
character encoding setting in Notepad's Save as dialog box. Presto,
å, ä, and ö are missing from the text when I open it in a simple
RichEditBox on a form.
If I on the other hand save the text using UTF-8 encoding in Notepad,
I can open the text in the RichTextBox and the characters I'm after
are intact.
Here's the code I use to read the text (found on-line):
[imports excluded!]
If File.Exists(sFileName) Then
Dim TextFileStream As TextReader
TextFileStream = File.OpenText(sFileName)
edtEditor.Text = TextFileStream.ReadToEnd
TextFileStream.Close()
End If
Here's the code I use to write the text (parts of it found on-line):
[imports excluded!]
Private Sub SaveIt(ByRef what As String, ByVal where As String)
Dim fileWriter As New StreamWriter(where)
fileWriter.WriteLine(what)
fileWriter.Close()
End Sub
TIA for any suggestions.
Oh, and I use this VB .NET 2005 Express Edition, if it matters.
--
Wedge