我有一个问题是正确读取二进制文件。 一个简单的例子是正确读取仅包含char permile(‰)的文件。
我尝试了很多解决方案:
使用二进制阅读器:
System::IO::FileStream^ stream = gcnew System::IO::FileStream(path, System::IO::FileMode::Open);
System::IO::BinaryReader^ reader = gcnew System::IO::BinaryReader(stream, System::Text::Encoding::UTF32);
array<Byte>^ bytes = gcnew array<Byte>(128);
do
{
bytes[i] = reader->ReadByte(); // the Byte in bytes[i] is not good
// ... some other code
} while (//condition);
我直接尝试使用StreamReader:
System::IO::StreamReader^ stream2 = gcnew System::IO::StreamReader(path);
array<wchar_t>^ bytes = gcnew arra<Byte>(128);
do
{
stream2->Read(bytes, 0, 128); // the Byte in bytes[i] is not good
// ... some other code
} while (//condition);
我从来没有成功地读过我的permile char。
我尝试更改编码方法(ASCII,UTF-8,UTF32等等)
有人有想法吗?
非常感谢,
巴普蒂斯特