Do not violate UTF-8 in XML output

According to UTF-8 encoding rules, there are no valid one byte long codepoints which start with a bigh bit set (i.e. 0x80 or higher value). Hence such XML output needs to be escaped, same as a control character.
This commit is contained in:
Bronek Kozicki
2018-03-12 20:34:13 +00:00
parent e11508b48a
commit 27fa7218ca
7 changed files with 57 additions and 8 deletions

View File

@@ -38,4 +38,8 @@ TEST_CASE( "XmlEncode" ) {
SECTION( "string with control char (x7F)" ) {
REQUIRE( encode( "[\x7F]" ) == "[\\x7F]" );
}
}
SECTION( "string with high bit set (x80 and xFF)" ) {
REQUIRE( encode( "[\x80]" ) == "[\\x80]" );
REQUIRE( encode( "[\xFF]" ) == "[\\xFF]" );
}
}