1. fixed bug in XmlEncode::encodeTo(): incorrect escaping of UTF-8 symbols

2. added test for XmlEncode in case of UTF-8 symbols
This commit is contained in:
Vladimir Zelyonkin
2016-04-05 10:00:15 +03:00
parent c984fc3ecd
commit 42d4e9f1b0
2 changed files with 7 additions and 4 deletions

View File

@@ -34,7 +34,7 @@ namespace Catch {
// (see: http://www.w3.org/TR/xml/#syntax)
for( std::size_t i = 0; i < m_str.size(); ++ i ) {
char c = m_str[i];
unsigned char c = m_str[i];
switch( c ) {
case '<': os << "&lt;"; break;
case '&': os << "&amp;"; break;
@@ -57,7 +57,7 @@ namespace Catch {
default:
// Escape control chars - based on contribution by @espenalb in PR #465
if ( ( c < '\x09' ) || ( c > '\x0D' && c < '\x20') || c=='\x7F' )
os << "&#x" << std::uppercase << std::hex << static_cast<int>( c );
os << "&#x" << std::uppercase << std::hex << static_cast<int>( c ) << ";";
else
os << c;
}