escape() fix for different SQChar sizes
This commit is contained in:
parent
737ea798a8
commit
b115b84dd1
@ -257,7 +257,19 @@ static SQInteger _string_escape(HSQUIRRELVM v)
|
||||
sq_push(v,2);
|
||||
return 1;
|
||||
}
|
||||
SQInteger destcharsize = (size * 6); //assumes every char could be escaped
|
||||
#ifdef SQUNICODE
|
||||
#if WCHAR_SIZE == 2
|
||||
const SQChar *escpat = _SC("\\x%04x");
|
||||
const SQInteger maxescsize = 6;
|
||||
#else //WCHAR_SIZE == 4
|
||||
const SQChar *escpat = _SC("\\x%08x");
|
||||
const SQInteger maxescsize = 10;
|
||||
#endif
|
||||
#else
|
||||
const SQChar *escpat = _SC("\\x%02x");
|
||||
const SQInteger maxescsize = 4;
|
||||
#endif
|
||||
SQInteger destcharsize = (size * maxescsize); //assumes every char could be escaped
|
||||
resstr = dest = (SQChar *)sq_getscratchpad(v,destcharsize * sizeof(SQChar));
|
||||
SQChar c;
|
||||
SQChar escch;
|
||||
@ -289,7 +301,8 @@ static SQInteger _string_escape(HSQUIRRELVM v)
|
||||
}
|
||||
}
|
||||
else {
|
||||
dest += scsprintf(dest,destcharsize,_SC("\\x%x"),c);
|
||||
|
||||
dest += scsprintf(dest, destcharsize, escpat, c);
|
||||
escaped++;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user