如何在C#中使用代码页437? [英] How to use code page 437 in C#?

查看:98
本文介绍了如何在C#中使用代码页437?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个类似于C#中的MS-DOS窗口的应用程序(使用富文本框).但是,问题是在读取二进制文件时我无法正确显示我的字符.有没有一种方法可以使这些字符与Lucida Console或Courier New这样的字体一起使用,或者我是否特别需要终端字体?我通过谷歌搜索发现了一些终端真实类型字体,但是与上面提到的其他两种字体相比,它们都不支持更多字符.我的程序应该能够显示代码页437中的所有字符(尽管字形不必看起来完全相同).

I am trying to create an application resembling a MS-DOS window in C# (using a rich text box). The problem, however, is that I cannot get my characters displayed correctly when reading a binary file. Is there a way of getting these characters to work with fonts like Lucida Console or Courier New, or do I specifically need a terminal font? I have found a few terminal true type fonts by googling, but none of them support any more characters than the other two above mentioned fonts. My program should be able to display all the characters in code page 437 (although the glyphs need not look exactly the same).

推荐答案

我怀疑您的文件包含Unicode字符.

如果是这样,并且您知道用于写入文件的编码,则可以使用
I suspect that your file contains Unicode characters.

If that is so and you know the encoding used to write the file, you can use the BinaryReader(stream, encoding)[^] overridden constructor. Then use the ReadChar()/ReadChars() method to get the characters for display.


MS LineDraw Font[^] might be an option for you.


这篇关于如何在C#中使用代码页437?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆