UTF8 & Textbox RichTextBox

ZeroEffect

Junior Contributor
Joined
Oct 24, 2004
Messages
204
Location
Detroit, MI
I would like to display a file in a textbox or RichTextbox. I how load the file but the file is encoded in UTF8 format. and some characters do not show. Like chr(0) chr(1) chr(3). Things that are not really displayed. Is there away to display these characters? I know it would be more of a "place holder" but that is what I would like.

Thanks

ZeroEffect
 
Thanks for the reply, this is how I am doing it.

Visual Basic:
        tbreadfromfile.Clear()
        Dim sr As New StreamReader(TextBox1.Text & ".dat", Encoding.UTF8)
        Dim data As Object = sr.ReadToEnd
        tbreadfromfile.Text = data
        sr.Close()
 
What is generating the file? Are you sure it is UTF-8 if it is containing invalid characters?

Just as an aside I would declare the variable data as a String rather than Object in your sample as ReadToEnd returns a string.
 
I'll make that change. I am makeing the file too.

Visual Basic:
        Dim sw As New System.IO.StreamWriter(TextBox1.Text & ".dat", False, Encoding.UTF8)

        Dim k As Integer = 4
        For i As Integer = 0 To holder.Length - 1
            If i = k Then
                k = k + 5
                sw.Write(Chr(0))
                sw.Write(Chr(1))
                sw.Write(Chr(2))
            Else

            End If
            sw.Write(Hex(Asc(holder.Substring(i, 1))))
            tbFinalOutput.AppendText(Hex(Asc(holder.Substring(i, 1))))

        Next
        sw.Write(Chr(0))
        sw.Close()
 
Back
Top