summaryrefslogtreecommitdiff
path: root/core/src/xmake/string
diff options
context:
space:
mode:
authorOpportunityLiu <[email protected]>2019-07-13 16:38:19 +0800
committerOpportunityLiu <[email protected]>2019-07-13 16:38:19 +0800
commitefe31e9a242029d3fc7c73ce95a12a69dcec029a (patch)
treed4d63d412dccbff27c00ae99635499cede35b534 /core/src/xmake/string
parentdf0db77c2455e15a436461c0b59e3e757651a9d2 (diff)
add check for convert
Diffstat (limited to 'core/src/xmake/string')
-rw-r--r--core/src/xmake/string/convert.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/core/src/xmake/string/convert.c b/core/src/xmake/string/convert.c
index a6edd5692..49ad3ca7a 100644
--- a/core/src/xmake/string/convert.c
+++ b/core/src/xmake/string/convert.c
@@ -53,12 +53,12 @@ static xm_charset_entry_t g_charsets[] =
, {TB_CHARSET_TYPE_GB2312, "gb2312" }
, {TB_CHARSET_TYPE_GBK, "gbk" }
, {TB_CHARSET_TYPE_ISO8859, "iso8859" }
-, {TB_CHARSET_TYPE_UCS2, "ucs2" }
-, {TB_CHARSET_TYPE_UCS4, "ucs4" }
-, {TB_CHARSET_TYPE_UTF16, "utf16" }
+, {TB_CHARSET_TYPE_UCS2 | TB_CHARSET_TYPE_NE, "ucs2" }
+, {TB_CHARSET_TYPE_UCS4 | TB_CHARSET_TYPE_NE, "ucs4" }
+, {TB_CHARSET_TYPE_UTF16 | TB_CHARSET_TYPE_NE, "utf16" }
, {TB_CHARSET_TYPE_UTF16 | TB_CHARSET_TYPE_BE, "utf16be" }
, {TB_CHARSET_TYPE_UTF16 | TB_CHARSET_TYPE_LE, "utf16le" }
-, {TB_CHARSET_TYPE_UTF32, "utf32" }
+, {TB_CHARSET_TYPE_UTF32 | TB_CHARSET_TYPE_NE, "utf32" }
, {TB_CHARSET_TYPE_UTF32 | TB_CHARSET_TYPE_BE, "utf32be" }
, {TB_CHARSET_TYPE_UTF32 | TB_CHARSET_TYPE_LE, "utf32le" }
, {TB_CHARSET_TYPE_UTF8, "utf8" }
@@ -115,6 +115,8 @@ tb_int_t xm_string_convert(lua_State* lua)
// find charsets
xm_charset_entry_ref_t fcharset = xm_string_charset_find_by_name(ftype_cstr);
xm_charset_entry_ref_t tcharset = xm_string_charset_find_by_name(ttype_cstr);
+ luaL_argcheck(lua, fcharset, 2, "charset not found");
+ luaL_argcheck(lua, tcharset, 3, "charset not found");
tb_check_return_val(fcharset && tcharset, 0);
// empty string?