1

is it possible to replace bytes to chars in this method:

byte[] sttrings = new byte[pntrs[i + 1] - pntrs[i]];
stream.Position = pntrs[i];
stream.Read(sttrings, 0, sttrings.Length);
Strs[i] = Encoding.GetEncoding("SHIFT-JIS").GetString(sttrings).Split('\0')[0].Replace("[FF00]", "/et");

where 0x00FF (in hex editor it is FF 00) is the byte i want to replace with "/et"

4

1 回答 1

2

假设您正在寻找 unicode char 0x00FF ( ÿ),您只需要使用Unicode 转义字符`\uxxxx。

byte[] sttrings = new byte[pntrs[i + 1] - pntrs[i]];
stream.Position = pntrs[i];
stream.Read(sttrings, 0, sttrings.Length);
Strs[i] = Encoding.GetEncoding("SHIFT-JIS").GetString(sttrings).Split('\0')[0].Replace("[\u00FF]" , "/et");

如果您真的想替换字节值,您可以使用接受 char[] 的 String 构造函数

string replacementString = new String(new char[] {'[', '\0', (char)0xFF, ']'});
于 2013-07-02T19:38:00.093 回答