diff --git a/helpers/inspect-library.c b/helpers/inspect-library.c
index 22c8c9e974c831a2b8ab69f4fab61d89cc7e08d3..a627985f3a247469069f6eae3fc9ce3fba5e7de9 100644
--- a/helpers/inspect-library.c
+++ b/helpers/inspect-library.c
@@ -485,11 +485,11 @@ main (int argc,
 static void
 print_json_string_content (const char *s)
 {
-  const char *p;
+  const unsigned char *p;
 
-  for (p = s; *p != '\0'; p++)
+  for (p = (const unsigned char *) s; *p != '\0'; p++)
     {
-      if (*p == '"' || *p == '\\' || *p <= 0x1F)
+      if (*p == '"' || *p == '\\' || *p <= 0x1F || *p >= 0x80)
         printf ("\\u%04x", *p);
       else
         printf ("%c", *p);