Commit 45752ab6 authored by cutealien's avatar cutealien

Bugfix: XML-Reader from ANSI->wchar_t should no longer mess up characters above 127

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3429 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 059af289
...@@ -373,6 +373,7 @@ namespace io ...@@ -373,6 +373,7 @@ namespace io
xmlChar<T>() {} xmlChar<T>() {}
xmlChar<T>(char in) : c(static_cast<T>(in)) {} xmlChar<T>(char in) : c(static_cast<T>(in)) {}
xmlChar<T>(wchar_t in) : c(static_cast<T>(in)) {} xmlChar<T>(wchar_t in) : c(static_cast<T>(in)) {}
explicit xmlChar<T>(unsigned char in) : c(static_cast<T>(in)) {}
explicit xmlChar<T>(unsigned short in) : c(static_cast<T>(in)) {} explicit xmlChar<T>(unsigned short in) : c(static_cast<T>(in)) {}
explicit xmlChar<T>(unsigned int in) : c(static_cast<T>(in)) {} explicit xmlChar<T>(unsigned int in) : c(static_cast<T>(in)) {}
explicit xmlChar<T>(unsigned long in) : c(static_cast<T>(in)) {} explicit xmlChar<T>(unsigned long in) : c(static_cast<T>(in)) {}
......
...@@ -670,9 +670,19 @@ private: ...@@ -670,9 +670,19 @@ private:
TextData = new char_type[sizeWithoutHeader]; TextData = new char_type[sizeWithoutHeader];
for (int i=0; i<sizeWithoutHeader; ++i) if ( sizeof(src_char_type) == 1 )
TextData[i] = static_cast<char_type>(source[i]); {
// we have to cast away negative numbers or results might add the sign instead of just doing a copy
for (int i=0; i<sizeWithoutHeader; ++i)
{
TextData[i] = static_cast<char_type>(static_cast<unsigned char>(source[i]));
}
}
else
{
for (int i=0; i<sizeWithoutHeader; ++i)
TextData[i] = static_cast<char_type>(source[i]);
}
TextBegin = TextData; TextBegin = TextData;
TextSize = sizeWithoutHeader; TextSize = sizeWithoutHeader;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment