, ASCII. ASCII - 7- . , ( 128 255), . ASCII .
-, Windows , . '\0'. , .
"" , ( , ). . :
byte[] fileBytes = File.ReadAllBytes("filename");
, , , . - :
StringBuilder sb = new StringBuilder();
foreach (var b in fileBytes)
{
if (b >= 32 || b == 10 || b == 13 || b = 9)
sb.Append((char)b);
else
{
switch (b)
{
case 0 : sb.Append("(nul)"); break;
case 27 : sb.Append("(esc)"); break;
}
}
}
, switch, , , . , , . - :
private Dictionary<byte, string> Conversions = new Dictionary<byte, string>()
{
{0, "(nul)"},
{27, "(esc)"},
};
:
foreach (var b in fileBytes)
{
string s;
if (Conversions.TryGetValue(b, out s))
{
sb.Append(s);
}
else
{
sb.Append((char)b);
}
}