private bool ReadEscapeCharacter(out char escapeCharacter)
{
char c;
int i, val;
// step over the leading '\\'
_scriptPosition++;
// determine the escape character
switch(GetBufferCharacter(_scriptPosition))
{
case '\\': c = '\\'; break;
case 'n': c = '\n'; break;
case 'r': c = '\r'; break;
case 't': c = '\t'; break;
case 'v': c = '\v'; break;
case 'b': c = '\b'; break;
case 'f': c = '\f'; break;
case 'a': c = '\a'; break;
case '\'': c = '\''; break;
case '\"': c = '\"'; break;
//case '\?': c = '\?'; break;
case 'x':
{
_scriptPosition++;
for(i = 0, val = 0; ; i++, _scriptPosition++)
{
c = GetBufferCharacter(_scriptPosition);
if((c >= '0') && (c <= '9'))
{
c = (char) (c - '0');
}
else if((c >= 'A') && (c <= 'Z'))
{
c = (char) (c - 'A' + 10);
}
else if((c >= 'a') && (c <= 'z'))
{
c = (char) (c - 'a' + 10);
}
else
{
break;
}
val = (val << 4) + c;
}
_scriptPosition--;
if(val > 0xFF)
{
Warning("too large value in escape character");
val = 0xFF;
}
c = (char) val;
break;
}
default: //NOTE: decimal ASCII code, NOT octal
{
if((GetBufferCharacter(_scriptPosition) < '0') || (GetBufferCharacter(_scriptPosition) > '9'))
{
Error("unknown escape char");
}
for(i = 0, val = 0; ; i++, _scriptPosition++)
{
c = GetBufferCharacter(_scriptPosition);
if((c >= '0') && (c <= '9'))
{
c = (char) (c - '0');
}
else
{
break;
}
val = val * 10 + c;
}
_scriptPosition--;
if(val > 0xFF)
{
Warning("too large value in escape character");
val = 0xFF;
}
c = (char) val;
break;
}
}
// step over the escape character or the last digit of the number
_scriptPosition++;
// store the escape character
escapeCharacter = c;
// succesfully read escape character
return true;
}