From 4016b9a7f02803e28582abb02cd410dcb5021fe6 Mon Sep 17 00:00:00 2001 From: Gert van Valkenhoef Date: Mon, 14 Nov 2011 11:33:14 +0000 Subject: [PATCH] Finally found out how 16 bit chars are encoded --- reader.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/reader.cc b/reader.cc index a57e9be..ffca53d 100644 --- a/reader.cc +++ b/reader.cc @@ -24,16 +24,20 @@ CHAR Reader::readLChar() { char *bufPtr = (char *)&buf; d_rider.read(bufPtr, 2); if (isLittleEndian()) { - return buf; + return buf - 0x8000; } else { CHAR out; char *outPtr = (char *)&out; outPtr[0] = bufPtr[1]; outPtr[1] = bufPtr[0]; - return out; + return out - 0x8000; } } void Reader::readLChar(CHAR *buf, size_t len) { + for (int i = 0; i < len; ++i) { + buf[i] = readLChar(); + } + /* char *bufPtr = (char *)buf; int len2 = len * 2; d_rider.read(bufPtr, len2); @@ -45,6 +49,7 @@ void Reader::readLChar(CHAR *buf, size_t len) { bufPtr[i + 1] = tmp; } } + */ } BYTE Reader::readByte() { -- 2.29.2