有些字符因不编码而被称为邪恶

时间:2013-08-22 12:49:28

标签: vb.net encoding

我正在编写一个程序来从Html文件中获取数据,但我的问题是在波斯语中收到的写得很差的字符。

其他语言:
有些字符因不编码而被称为邪恶 例如, 该

我的代码是:

Imports System.IO
Public Class Form1

   Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
       OpenFileDialog1.ShowDialog()
       Dim pfile As String
       pfile = OpenFileDialog1.FileName.ToString
       Dim a As System.Text.Encoding
       a = System.Text.Encoding.UTF8 '' I used other encoding Such as default assci windows-1257 and ... but not fix!!
       Dim k_reader As New StreamReader(pfile.ToString, a)
       RichTextBox1.Text = k_reader.ReadToEnd

   End Sub
End Class

1 个答案:

答案 0 :(得分:3)

显然你猜错了编码错误,它不是utf8。查看实际的HTML文件时很容易看到:

  <meta http-equiv="Content-Type" content="text/html; charset=windows-1256">

所以修复你使用的编码:

  a = System.Text.Encoding.GetEncoding(1256)