diff options
author | David Tardon <dtardon@redhat.com> | 2017-07-29 14:01:22 +0200 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2017-07-29 14:01:44 +0200 |
commit | 59c14218dcba5ba624c8e5a8f36920b2ede88200 (patch) | |
tree | d381e32a51523efe56b98a1b802fd1ad83ed951b | |
parent | fe94ee29757054600e9f12430ce5c59b805d2150 (diff) |
do not append UTF-8 string by code unit
-rw-r--r-- | src/lib/SW602Types.cpp | 9 |
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); } } |