如何在不检索 'ß' 或"ä"等字符的情况下从文本文件中读取文本?



当我使用VBO实用程序 - 文件管理时,从文本文件中获取文本非常容易。 不幸的是,它会返回像"ß"、"ü"或"ä"这样的字符。那么如何消除并获得正确的字符呢?

您可能正在处理的文件使用与标准编码不同的编码。要阅读它,您需要改进 VBO,以便能够指定它。

您可以在下面找到我正在使用的代码。

Try
If File.Exists(File_Name) Then
if Encoding_Type = "" then
Dim sr As New StreamReader(File_Name)
Text = sr.ReadToEnd
sr.Close()
else
Dim sr2 As New StreamReader(File_Name,Encoding.GetEncoding(CInt(Encoding_Type)))
Text = sr2.ReadToEnd
sr2.Close()
end if
Success = True
Message = ""
Else
Throw New ApplicationException("The file at " & File_Name & " does not exist")
End If
Catch e As Exception
Success = False
Message = e.Message
End Try

对于德语字母,它可能应该编码 28591。

您可以在本网站阅读有关编码的更多信息:https://learn.microsoft.com/en-us/dotnet/api/system.text.encodinginfo.getencoding?view=netframework-4.7.2

相关内容

最新更新