diff --git a/Source/cmXMLSafe.cxx b/Source/cmXMLSafe.cxx index 861d75c0b..21b6bc33c 100644 --- a/Source/cmXMLSafe.cxx +++ b/Source/cmXMLSafe.cxx @@ -60,7 +60,7 @@ cmsys_ios::ostream& operator<<(cmsys_ios::ostream& os, cmXMLSafe const& self) char const* last = self.Data + self.Size; for(char const* ci = first; ci != last; ++ci) { - char c = *ci; + unsigned char c = static_cast(*ci); switch(c) { case '&': os << "&"; break; @@ -74,16 +74,15 @@ cmsys_ios::ostream& operator<<(cmsys_ios::ostream& os, cmXMLSafe const& self) default: if(c >= 0x20 && c <= 0x7f) { - os.put(c); + os.put(static_cast(c)); } else { // TODO: More complete treatment of program output character // encoding. Instead of escaping these bytes, we should // handle the current locale and its encoding. - unsigned char uc = static_cast(c); char buf[16]; - sprintf(buf, "&#x%hx;", static_cast(uc)); + sprintf(buf, "&#x%hx;", static_cast(c)); os << buf; } break;