1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
From: Simon McVittie <smcv@debian.org>
Date: Tue, 4 Jan 2022 19:47:42 +0000
Subject: 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.
Bug: https://gitlab.gnome.org/GNOME/pango/-/issues/652
Signed-off-by: Simon McVittie <smcv@debian.org>
Forwarded: https://gitlab.gnome.org/GNOME/pango/-/merge_requests/572
---
pango/json/gtkjsonprinter.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pango/json/gtkjsonprinter.c b/pango/json/gtkjsonprinter.c
index f2f1e27..e9ca03a 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));
|