Commit 2f8448a5 authored by Peter Eastman's avatar Peter Eastman
Browse files

irrXML supports numeric escapes

parent 90ddfc31
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// This file is part of the "Irrlicht Engine" and the "irrXML" project. // This file is part of the "Irrlicht Engine" and the "irrXML" project.
// For conditions of distribution and use, see copyright notice in irrlicht.h and/or irrXML.h // For conditions of distribution and use, see copyright notice in irrlicht.h and/or irrXML.h
// MODIFIED by Peter Eastman, Feb. 4, 2016, to support numeric escape sequences
#ifndef __ICXML_READER_IMPL_H_INCLUDED__ #ifndef __ICXML_READER_IMPL_H_INCLUDED__
#define __ICXML_READER_IMPL_H_INCLUDED__ #define __ICXML_READER_IMPL_H_INCLUDED__
...@@ -529,10 +531,37 @@ private: ...@@ -529,10 +531,37 @@ private:
pos += SpecialCharacters[specialChar].size(); pos += SpecialCharacters[specialChar].size();
} }
else else
{
int semicolonPos = origstr.findNext(L';', pos);
if (semicolonPos != -1 && origstr.c_str()[pos+1] == L'#')
{
// it is a numeric character reference
int number;
core::string<char> numberString;
if (origstr.c_str()[pos+2] == L'x')
{
// hex value
for (int i=pos+3; i<semicolonPos; ++i)
numberString.append((char) origstr[i]);
sscanf(numberString.c_str(), "%x", &number);
}
else
{
// decimal value
for (int i=pos+2; i<semicolonPos; ++i)
numberString.append((char) origstr[i]);
sscanf(numberString.c_str(), "%d", &number);
}
newstr.append(origstr.subString(oldPos, pos - oldPos));
newstr.append((char_type) number);
pos = semicolonPos+1;
}
else
{ {
newstr.append(origstr.subString(oldPos, pos - oldPos + 1)); newstr.append(origstr.subString(oldPos, pos - oldPos + 1));
pos += 1; pos += 1;
} }
}
// find next & // find next &
oldPos = pos; oldPos = pos;
......
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