Fixed a bug in the UTF-8 -> UTF-32 conversion when the input character type is signed

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1577 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
laurentgom 2010-10-11 08:37:21 +00:00
parent 274014e786
commit 77078f53db

View File

@ -45,18 +45,18 @@ In Utf<8>::Decode(In begin, In end, Uint32& output, Uint32 replacement)
};
// Decode the character
int trailingBytes = trailing[static_cast<int>(*begin)];
int trailingBytes = trailing[static_cast<Uint8>(*begin)];
if (begin + trailingBytes < end)
{
output = 0;
switch (trailingBytes)
{
case 5 : output += *begin++; output <<= 6;
case 4 : output += *begin++; output <<= 6;
case 3 : output += *begin++; output <<= 6;
case 2 : output += *begin++; output <<= 6;
case 1 : output += *begin++; output <<= 6;
case 0 : output += *begin++;
case 5 : output += static_cast<Uint8>(*begin++); output <<= 6;
case 4 : output += static_cast<Uint8>(*begin++); output <<= 6;
case 3 : output += static_cast<Uint8>(*begin++); output <<= 6;
case 2 : output += static_cast<Uint8>(*begin++); output <<= 6;
case 1 : output += static_cast<Uint8>(*begin++); output <<= 6;
case 0 : output += static_cast<Uint8>(*begin++);
}
output -= offsets[trailingBytes];
}