Text imported from text to textbox file does not display the seats correctly

Asked

Viewed 35 times

0

I’m developing a Notepad and I’m having trouble importing text from a text file where that text has several seats, but after importing to a multi-line textbox , instead of the seats a different symbol appears. As in the image below Texto importado

I’ve tried some ways but it looks the same this was the last code I tried

OpenFileDialog1.Title = "Open Text File"
    OpenFileDialog1.InitialDirectory = "C:\"
    OpenFileDialog1.ShowDialog()

    Dim textFile As StreamReader

    textFile = File.OpenText(OpenFileDialog1.FileName)
    TextBox1.Text = textFile.ReadToEnd()

    textFile.Close()

1 answer

0

In fact after several attempts and searching I found 2 solutions in which I used. in fact the first situation was to re-save the text file with utf-8 and the second I applied in code I found online Social msn forum This is my current code:

Public Function RemoveAcentos(ByVal texto As String) As String
    Dim charFrom As String = "ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ"
    Dim charTo As String = "SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy"
    For i As Integer = 0 To charFrom.Length - 1
        texto = Replace(texto, charFrom(i), charTo(i))
    Next
    Return texto
End Function

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
    TextBox1.Text = RemoveAcentos(TextBox1.Text.ToString)
End Sub

Browser other questions tagged

You are not signed in. Login or sign up in order to post.