summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2017-07-29 14:01:22 +0200
committerDavid Tardon <dtardon@redhat.com>2017-07-29 14:01:44 +0200
commit59c14218dcba5ba624c8e5a8f36920b2ede88200 (patch)
treed381e32a51523efe56b98a1b802fd1ad83ed951b
parentfe94ee29757054600e9f12430ce5c59b805d2150 (diff)
do not append UTF-8 string by code unit
-rw-r--r--src/lib/SW602Types.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/lib/SW602Types.cpp b/src/lib/SW602Types.cpp
index 2c256a2..d13e2fa 100644
--- a/src/lib/SW602Types.cpp
+++ b/src/lib/SW602Types.cpp
@@ -71,15 +71,16 @@ void appendUnicode(uint32_t val, librevenge::RVNGString &buffer)
len = 6;
}
- uint8_t outbuf[6] = { 0, 0, 0, 0, 0, 0 };
+ char outbuf[7] = { 0 };
int i;
for (i = len - 1; i > 0; --i)
{
- outbuf[i] = uint8_t((val & 0x3f) | 0x80);
+ outbuf[i] = char((val & 0x3f) | 0x80);
val >>= 6;
}
- outbuf[0] = uint8_t(val | first);
- for (i = 0; i < len; i++) buffer.append((char)outbuf[i]);
+ outbuf[0] = char((val & 0xff) | first);
+ outbuf[len] = '\0';
+ buffer.append(outbuf);
}
}