流阅读器不读取SuperScript字符

时间:2018-10-15 12:29:11

标签: vb.net streamreader

我正在使用StreamReader将数据从Tab Delim文本文件导入到称为“导入数据”的数据表中。出于某些原因,一旦将SuperScript字符导入表,就无法读取。

例如,如果我在文本文件中具有ProductName值“ 360°旋转式通用手指环支架”,则导入后该值将变为“ 360°旋转式通用手指环支架”。与其他字符“®,™”相同“。

我的代码有什么关系吗?

Public Function FillData(ByVal Fpath As String) As Boolean
        Dim XRead As System.IO.StreamReader = New IO.StreamReader(FilePath)
        Dim XLine As String = Nothing
        Dim XSplitLine() As String
        Dim i As Integer = ImportedData.Rows.Count + 1
        Try
            XRead.ReadLine()
            XLine = XRead.ReadLine()
            Do Until XLine Is Nothing

                XLine = i & vbTab & XLine & vbTab & FilePath
                XSplitLine = XLine.Split(CType(vbTab, Char()))

                ImportedData.Rows.Add(XSplitLine)
                XLine = XRead.ReadLine
                i += 1
            Loop
            XRead.Close()

        Catch ex As Exception
            MessageBox.Show("Error")
            Return False
            Exit Function
        End Try

        Return True
    End Function

1 个答案:

答案 0 :(得分:0)

Dim XRead As System.IO.StreamReader = New IO.StreamReader(FilePath,Text.encoding.DefaultEncoding)

应该能够正确阅读此内容。