aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2020-10-05 16:01:55 +0200
committerPierre Ossman <ossman@cendio.se>2020-10-05 16:01:55 +0200
commit6345c0f60f37f598a40536578938a6cd623b6e7f (patch)
treeb9e6061c55b7a3142fc4cee1219dad719b4fb962 /common
parente61ff736c150f06cee968ad4530db6bf83de5db3 (diff)
downloadtigervnc-6345c0f60f37f598a40536578938a6cd623b6e7f.tar.gz
tigervnc-6345c0f60f37f598a40536578938a6cd623b6e7f.zip
Fix UTF-16 encoding/decoding of high code points
Everything outside of BMP was handled incorrectly and was coded as completely different code points.
Diffstat (limited to 'common')
-rw-r--r--common/rfb/util.cxx7
1 files changed, 4 insertions, 3 deletions
diff --git a/common/rfb/util.cxx b/common/rfb/util.cxx
index 00e2831c..85b668fc 100644
--- a/common/rfb/util.cxx
+++ b/common/rfb/util.cxx
@@ -315,8 +315,9 @@ namespace rfb {
*dst++ = L'\0';
return 1;
} else if (src < 0x110000) {
- *dst++ = 0xd800 | ((src >> 10) & 0x07ff);
- *dst++ = 0xdc00 | (src & 0x07ff);
+ src -= 0x10000;
+ *dst++ = 0xd800 | ((src >> 10) & 0x03ff);
+ *dst++ = 0xdc00 | (src & 0x03ff);
*dst++ = L'\0';
return 2;
} else {
@@ -358,7 +359,7 @@ namespace rfb {
return 1;
}
- *dst = 0x10000 | ((*dst & 0x03ff) << 10);
+ *dst = 0x10000 + ((*dst & 0x03ff) << 10);
*dst |= *src & 0x3ff;
return 2;