打印大于0x7f的ASCII字符 [英] printing ASCII character greater than 0x7f

查看:361
本文介绍了打印大于0x7f的ASCII字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目中遇到过一种情况,我在这里阅读了一个带有

的文本文件,其中一些字符大于十六进制0x7f。


i需要写字符(0xE0)将新文件作为例外。然而,当我想要通过Console.Write来写这个时候。或filestream.Write或似乎价值变化了。
。大多数输出​​文件都处于文本模式。


如果我以二进制模式查看原始文件,我会看到我有这个角色的问题
问题作为e0 00但当我重写它时,我得到C3 A0。


我无法在输出文件中重现读取信息。有没有

这样做的方法,如果是这样的话?

i have come across a situation in my project where i read a text file with
some characters greater than hex 0x7f.

i need to write character (0xE0) to a new file as an exception. however when
i attempt to write this via "Console.Write" or "filestream.Write" it seems
the value changes. most of the output file is in text mode.

if i view the original file in binary mode i see the character i''m having
issue with as "e0 00" but when i re-write it i get "C3 A0".

i just can not reproduce the read information in my output file. is there
way to do this and if so how?

推荐答案

嗯,ASCII没有定义任何字符在此之上。你需要知道

文件的代码页,并使用正确的编码 - 通过(对于

示例)Encoding.GetEncoding(int codepage)[并将此编码传递给

您正在使用的StreamReader等。


否则,将进行翻译。而且他们是否代表您的原始数据是否是任何人的猜测。


Marc
Well, ASCII doesn''t define any characters above this. You need to know
the codepage of the file, and use the correct encoding - via (for
example) Encoding.GetEncoding(int codepage) [and pass this encoding into
whichever StreamReader etc you are using].

Otherwise, translations will occur. And whether they represent your
original data is anyone''s guess.

Marc


有没有找到代码页?是否有一个很好的参考资料来源?


" Marc Gravell"写道:
is there away to find the codepage? is there a good reference source?

"Marc Gravell" wrote:

好​​吧,ASCII并没有定义任何高于此的字符。你需要知道

文件的代码页,并使用正确的编码 - 通过(对于

示例)Encoding.GetEncoding(int codepage)[并将此编码传递给

您正在使用的StreamReader等。


否则,将进行翻译。而且他们是否代表您的原始数据是否是任何人的猜测。


Marc
Well, ASCII doesn''t define any characters above this. You need to know
the codepage of the file, and use the correct encoding - via (for
example) Encoding.GetEncoding(int codepage) [and pass this encoding into
whichever StreamReader etc you are using].

Otherwise, translations will occur. And whether they represent your
original data is anyone''s guess.

Marc

6月9日下午4:10,auldh< au ... @ discussion.microsoft.comwrote:
On Jun 9, 4:10 pm, auldh <au...@discussions.microsoft.comwrote:

即可找到代码页?有一个很好的参考资料来源吗?
is there away to find the codepage? is there a good reference source?



确定文件的代码页没有硬性规则。

单个文件(即一个字节序列) )对于几个不同的代码页,可能有效(但

不同的含义)。


Jon

There''s no hard and fast rule for determining the codepage of a file.
A single file (i.e. a sequence of bytes) may be valid (but with
different meanings) for several different codepages.

Jon


这篇关于打印大于0x7f的ASCII字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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