1
0
mirror of https://github.com/borgesdan/xn65 synced 2024-12-29 21:54:47 +01:00

Implementações em ReadChar

This commit is contained in:
Danilo Borges Santos 2024-12-09 15:35:29 -03:00
parent 3bc10d36d2
commit 5957633790
3 changed files with 10 additions and 10 deletions

View File

@ -135,7 +135,7 @@ namespace csharp {
std::shared_ptr<Stream> _stream;
bool _leaveOpen;
bool _disposed{false};
bool _2BytesPerChar{ false };
bool _2BytesPerChar{ true };
std::vector<uint8_t> _auxBuffer;
};

View File

@ -13,6 +13,9 @@ namespace xna {
Game1() : Game() {
Content()->RootDirectory("Content");
short inteiro = 0xC3 | 0xA7;
char charpa = inteiro;
auto stream = std::make_shared<csharp::FileStream>("D:/file.bin", csharp::FileMode::Open);
auto reader = csharp::BinaryReader(stream);
auto bo = reader.ReadBoolean(); //reader.ReadChar()

View File

@ -32,15 +32,13 @@ namespace csharp {
{
posSav = _stream->Position();
}
auto charBytes = std::vector<uint8_t>(MaxCharBytesSize);
char singleChar = '\0';
while (charsRead == 0) {
numBytes = _2BytesPerChar ? 2 : 1;
auto r = _stream->ReadByte();
charBytes[0] = static_cast<uint8_t>(r);
auto r = _stream->ReadByte();
if (r == -1)
{
@ -48,13 +46,12 @@ namespace csharp {
}
if (numBytes == 2)
{
r = _stream->ReadByte();
charBytes[1] = static_cast<uint8_t>(r);
r |= _stream->ReadByte();
if (r == -1)
{
numBytes = 1;
}
}
}
if (numBytes == 0)
@ -62,8 +59,8 @@ namespace csharp {
return -1;
}
const auto chars = reinterpret_cast<char*>(charBytes.data());
const auto decoder = std::string(chars);
const char chars = r;
const auto decoder = std::string(&chars);
charsRead = decoder.size();
singleChar = decoder[0];
}