-2

I am writing a program to get data from a Html file, but my problem is that badly written characters that are received in Farsi.

In other languages:
Some characters are called evil for not encodeing
For example, the The ���� � ����� ������

my code is :

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
4

1 に答える 1

3

エンコーディングが間違っていると推測したのは明らかです。utf8 ではありません。実際の HTML ファイルを見ると簡単に確認できます。

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

したがって、使用するエンコーディングを修正します。

  a = System.Text.Encoding.GetEncoding(1256)
于 2013-08-22T14:25:00.190 に答える