使用一个空格替换文本文件中的不可见十六进制字符(A0,B0,E0,F2) [英] replace the invisible hex characters (A0, B0, E0, F2) in the text file using one space

查看:123
本文介绍了使用一个空格替换文本文件中的不可见十六进制字符(A0,B0,E0,F2)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本文件,我想用一个空格替换文本文件中不可见的十六进制字符(A0,B0,E0,F2)。我正在使用十六进制编辑器手动执行。但我想使用csharp代码作为要求。因为我是C sharp的新人。你可以帮助我吗?

I have one text file and I want to replace the invisible hex characters (A0, B0, E0, F2) in the text file using one space. I am using hex editors to do manually . But I want to use a csharp code as a requirement. As I am new in C sharp . can you help me ?

推荐答案

简单:

Easy:
private static byte[] removeThese = { 0xA0, 0xB0, 0xE0, 0xF2 };
private void button1_Click(object sender, EventArgs e)
    {
    byte[] bytes = File.ReadAllBytes(@"D:\Temp\infile.txt");
    byte[] outp = bytes.Select(c => removeThese.Contains(c) ? (byte)' ' : c).ToArray();
    File.WriteAllBytes(@"D:\Temp\outputfile.txt", outp);
    }


这篇关于使用一个空格替换文本文件中的不可见十六进制字符(A0,B0,E0,F2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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