summaryrefslogtreecommitdiffstats
path: root/generic/tclDisassemble.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclDisassemble.c')
-rw-r--r--generic/tclDisassemble.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/generic/tclDisassemble.c b/generic/tclDisassemble.c
index 15502e7..86f0e1d 100644
--- a/generic/tclDisassemble.c
+++ b/generic/tclDisassemble.c
@@ -833,8 +833,19 @@ PrintSourceToObj(
continue;
default:
#if TCL_UTF_MAX > 4
- if ((int) ch > 0xffff) {
- Tcl_AppendPrintfToObj(appendObj, "\\U%08x", (int) ch);
+ if (ch > 0xffff) {
+ Tcl_AppendPrintfToObj(appendObj, "\\U%08x", ch);
+ i += 10;
+ } else
+#elif TCL_UTF_MAX > 3
+ /* If len == 0, this means we have a char > 0xffff, resulting in
+ * TclUtfToUniChar producing a surrogate pair. We want to output
+ * this pair as a single Unicode character.
+ */
+ if (len == 0) {
+ int upper = ((ch & 0x3ff) + 1) << 10;
+ len = TclUtfToUniChar(p, &ch);
+ Tcl_AppendPrintfToObj(appendObj, "\\U%08x", upper + (ch & 0x3ff));
i += 10;
} else
#endif