|
@@ -257,7 +257,19 @@ static SQInteger _string_escape(HSQUIRRELVM v)
|
|
|
sq_push(v,2);
|
|
sq_push(v,2);
|
|
|
return 1;
|
|
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));
|
|
resstr = dest = (SQChar *)sq_getscratchpad(v,destcharsize * sizeof(SQChar));
|
|
|
SQChar c;
|
|
SQChar c;
|
|
|
SQChar escch;
|
|
SQChar escch;
|
|
@@ -289,7 +301,8 @@ static SQInteger _string_escape(HSQUIRRELVM v)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
- dest += scsprintf(dest,destcharsize,_SC("\\x%x"),c);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ dest += scsprintf(dest, destcharsize, escpat, c);
|
|
|
escaped++;
|
|
escaped++;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|