流读取器不读取上标字符



我正在使用StreamReader将数据从Tab Delim文本文件导入到名为"导入数据"的数据表中。由于某些原因,任何上标字符一旦导入表就不可读。

例如,如果我在文本文件中有一个 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
Dim XRead As System.IO.StreamReader = New IO.StreamReader(FilePath,Text.encoding.DefaultEncoding)

应该能够正确阅读。

最新更新