]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
Set UTF-8 encoding for XML reports 531/head
authorMarek Küthe <m.k@mk16.de>
Sun, 13 Apr 2025 11:58:08 +0000 (11:58 +0000)
committerMarek Küthe <m.k@mk16.de>
Sun, 13 Apr 2025 12:00:00 +0000 (12:00 +0000)
ui/mtr.c
ui/report.c

index 81417712af6727f0a1f3f18bd7f2ee144dea7c27..4d5a343d5957158a4b5dc26c5b9cd3e56f73039c 100644 (file)
--- a/ui/mtr.c
+++ b/ui/mtr.c
@@ -44,6 +44,7 @@
 #include <assert.h>
 #include <fcntl.h>
 #include <limits.h>
+#include <locale.h>
 #include <sys/stat.h>
 #include <sys/time.h>
 
@@ -776,6 +777,9 @@ int main(
     /* This will check if stdout/stderr writing is successful */
     atexit(close_stdout);
 
+    /* Set encoding for reports */
+    setlocale(LC_CTYPE, "C.UTF-8");
+
     /* reset the random seed */
     init_rand();
 
index 364a9befd43ed3ab184e76fc0f64671436b06b54..4b03c0d78afab2985d217b138d2fe847b0294a2c 100644 (file)
@@ -408,7 +408,7 @@ void xml_close(
     char name[MAX_FORMAT_STR];
     char buf[128];
 
-    printf("<?xml version=\"1.0\"?>\n");
+    printf("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
     printf("<MTR SRC=\"%s\" DST=\"%s\"", ctl->LocalHostname,
            ctl->Hostname);
     printf(" TOS=\"0x%X\"", ctl->tos);