如何显示带有特殊编码的消息

How to display message with special encoding

我正在编写一个程序,我需要从文件中读取文本,并在鼠标悬停在数据点上时将其显示在图表上。我的问题是,当我从文本文件中读取数据并将其显示在图表上时,它显示了一些“?”而不是实际角色。 (无法 post 图片抱歉)

这是我从文件中读取并尝试更改编码的代码。(没有成功):

string myString = File.ReadAllText(@"read.txt");

        Encoding enc_to = Encoding.GetEncoding("iso-8859-1");
        Encoding enc_from = Encoding.UTF8;
        byte[] InitialBytes =enc_from.GetBytes(myString);
        byte[] FinalBytes = Encoding.Convert(enc_from, enc_to, InitialBytes);
        string myMessage = enc_to.GetString(FinalBytes);

请注意,我不想将字符串显示为 MessageBox.Show,而是希望将其显示为工具提示。

这是 read.txt 文件中的文本:

3 stands of 5½"

显示方式如下:

3 stands of 5�"

使用Encoding.Default:

string myString = File.ReadAllText(@"read.txt",Encoding.Default);