Escape all non-printable characters so that we generate valid PDML.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@31674
f5534014-38df-0310-8fa8-
9805f1628bb7
print_escaped_xml(FILE *fh, const char *unescaped_string)
{
const char *p;
+ char temp_str[8];
for (p = unescaped_string; *p != '\0'; p++) {
switch (*p) {
fputs("'", fh);
break;
default:
- fputc(*p, fh);
+ if (g_ascii_isprint(*p))
+ fputc(*p, fh);
+ else {
+ g_snprintf(temp_str, sizeof(temp_str), "\\x%x", (guint8)*p);
+ fputs(temp_str, fh);
+ }
}
}
}