summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2022-01-04 19:47:42 +0000
committerSimon McVittie <smcv@debian.org>2022-01-04 19:52:12 +0000
commit18235a64c08b6dac3be5d368f3baaee285cabc3d (patch)
tree05993b71839a83fb8700e318a5af5fb7ebc98165
parent05699b666d1138bd8268fd708e3047b4c4a26b65 (diff)
downloadpango-18235a64c08b6dac3be5d368f3baaee285cabc3d.tar.gz
serializer: Serialize non-ASCII correctly if char is unsigned
If char is unsigned, the first byte of a non-trivial UTF-8 sequence will be 0x80 or higher, instead of being negative. In this case we need to process it as UTF-8, instead of printing only the first byte and then skipping to the next UTF-8 character. char is usually signed on x86 and some other architectures, but not on the ARM or PowerPC families, among others. Resolves: https://gitlab.gnome.org/GNOME/pango/-/issues/652 Signed-off-by: Simon McVittie <smcv@debian.org>
-rw-r--r--pango/json/gtkjsonprinter.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/pango/json/gtkjsonprinter.c b/pango/json/gtkjsonprinter.c
index f2f1e273..e9ca03a3 100644
--- a/pango/json/gtkjsonprinter.c
+++ b/pango/json/gtkjsonprinter.c
@@ -226,7 +226,7 @@ gtk_json_printer_escape_string (GtkJsonPrinter *self,
g_string_append (string, "\\t");
break;
default:
- if ((int) *str < 0x20)
+ if ((int) *str < 0x20 || (int) *str >= 0x80)
{
if ((guint) *str < 0x20 || gtk_json_printer_has_flag (self, GTK_JSON_PRINTER_ASCII))
g_string_append_printf (string, "\\u%04x", g_utf8_get_char (str));