我正在尝试将严格的二进制数据写入文件(无编码)。问题是,当我对文件进行十六进制转储时,我注意到了相当奇怪的行为。使用以下任一方法构造文件都会导致相同的行为。我什至使用 System::Text::Encoding::Default 来测试流。
StreamWriter^ binWriter = gcnew StreamWriter(gcnew FileStream("test.bin",FileMode::Create));
(Also used this method)
FileStream^ tempBin = gcnew FileStream("test.bin",FileMode::Create);
BinaryWriter^ binWriter = gcnew BinaryWriter(tempBin);
binWriter->Write(0x80);
binWriter->Write(0x81);
.
.
binWriter->Write(0x8F);
binWriter->Write(0x90);
binWriter->Write(0x91);
.
.
binWriter->Write(0x9F);
写入该字节序列,我注意到在十六进制转储中唯一未转换为 0x3F 的字节是 0x81,0x8D,0x90,0x9D ...我不知道为什么。
我也尝试过制作字符数组,类似的情况也发生了。IE,
array<wchar_t,1>^ OT_Random_Delta_Limits = {0x00,0x00,0x03,0x79,0x00,0x00,0x04,0x88};
binWriter->Write(OT_Random_Delta_Limits);
0x88 将被写为 0x3F。
有任何想法吗?