|
|
@@ -222,7 +222,9 @@ static SQRESULT base_gettypetag(HSQUIRRELVM v)
|
|
|
static SQRESULT base_getdefaultdelegate(HSQUIRRELVM v)
|
|
|
{
|
|
|
if(sq_getdefaultdelegate(v, sq_gettype(v, 2)) != SQ_OK)
|
|
|
+ {
|
|
|
sq_pushnull(v);
|
|
|
+ }
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
@@ -2007,6 +2009,20 @@ static SQRESULT string_count_char(HSQUIRRELVM v)
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
+static SQRESULT string_uchar(HSQUIRRELVM v)
|
|
|
+{
|
|
|
+ SQ_FUNC_VARS_NO_TOP(v);
|
|
|
+ SQ_GET_STRING(v, 1, str);
|
|
|
+ SQ_GET_INTEGER(v, 2, char_idx);
|
|
|
+ if((char_idx >= str_size) || (char_idx < 0))
|
|
|
+ {
|
|
|
+ return sq_throwerror(v, _SC("index out of range"));
|
|
|
+ }
|
|
|
+ sq_pushinteger(v, (SQUChar)(str[char_idx]));
|
|
|
+ return 1;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
#define MMIN(a,b) (((a)<(b))?(a):(b))
|
|
|
static SQRESULT string_edit_distance (HSQUIRRELVM v) {
|
|
|
SQ_FUNC_VARS(v);
|
|
|
@@ -2246,6 +2262,7 @@ SQRegFunction SQSharedState::_string_default_delegate_funcz[]={
|
|
|
{_SC("isalpha"),string_isalpha,2, _SC("si")},
|
|
|
{_SC("isdigit"),string_isdigit,2, _SC("si")},
|
|
|
{_SC("count_char"),string_count_char,2, _SC("si")},
|
|
|
+ {_SC("uchar"),string_uchar,2, _SC("si")},
|
|
|
{_SC("edit_distance"),string_edit_distance,-2, _SC("ssi")},
|
|
|
{_SC("mod_97_10"),string_mod_97_10,1, _SC("s")},
|
|
|
{_SC("iso88959_to_utf8"),string_iso88959_to_utf8,1, _SC("s")},
|