diff --git a/lib/errorlogger.cpp b/lib/errorlogger.cpp
index 5058c56c2..f1ed62047 100644
--- a/lib/errorlogger.cpp
+++ b/lib/errorlogger.cpp
@@ -396,7 +396,7 @@ std::string ErrorLogger::ErrorMessage::toXML() const
         printer.PushAttribute("file", (*it).getfile().c_str());
         printer.PushAttribute("line", std::max((*it).line,0));
         if (!it->getinfo().empty())
-            printer.PushAttribute("info", it->getinfo().c_str());
+            printer.PushAttribute("info", fixInvalidChars(it->getinfo()).c_str());
         printer.CloseElement(false);
     }
     for (std::string::size_type pos = 0; pos < mSymbolNames.size();) {
diff --git a/test/testerrorlogger.cpp b/test/testerrorlogger.cpp
index 8dba23d78..e174cb8f3 100644
--- a/test/testerrorlogger.cpp
+++ b/test/testerrorlogger.cpp
@@ -197,6 +197,7 @@ private:
 
     void ToXmlV2Locations() const {
         std::list<ErrorLogger::ErrorMessage::FileLocation> locs = { fooCpp5, barCpp8 };
+        locs.back().setinfo("รค");
         ErrorMessage msg(locs, emptyString, Severity::error, "Programming error.\nVerbose error", "errorId", false);
         std::string header("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<results version=\"2\">\n");
         header += "    <cppcheck version=\"";
@@ -206,7 +207,7 @@ private:
         ASSERT_EQUALS("    </errors>\n</results>", ErrorLogger::ErrorMessage::getXMLFooter());
         std::string message("        <error id=\"errorId\" severity=\"error\"");
         message += " msg=\"Programming error.\" verbose=\"Verbose error\">\n";
-        message += "            <location file=\"bar.cpp\" line=\"8\"/>\n";
+        message += "            <location file=\"bar.cpp\" line=\"8\" info=\"\\303\\244\"/>\n";
         message += "            <location file=\"foo.cpp\" line=\"5\"/>\n        </error>";
         ASSERT_EQUALS(message, msg.toXML());
     }