diff options
| author | OpportunityLiu <[email protected]> | 2019-07-01 14:19:05 +0800 |
|---|---|---|
| committer | OpportunityLiu <[email protected]> | 2019-07-01 14:19:05 +0800 |
| commit | f40152174188626df4b70ca1b9044a721fd3c6e8 (patch) | |
| tree | 388f5b8e3acdcf1bc9253556fe762dc8b09a5d2a /core/src/xmake/string | |
| parent | 19cbd06f95dddacd1247d1dffab9fa29d719d02b (diff) | |
utf8 support
Diffstat (limited to 'core/src/xmake/string')
| -rw-r--r-- | core/src/xmake/string/convert.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/core/src/xmake/string/convert.c b/core/src/xmake/string/convert.c index 32e5088ed..693a605ee 100644 --- a/core/src/xmake/string/convert.c +++ b/core/src/xmake/string/convert.c @@ -52,7 +52,7 @@ 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, "ucs3" } +, {TB_CHARSET_TYPE_UCS2, "ucs2" } , {TB_CHARSET_TYPE_UCS4, "ucs4" } , {TB_CHARSET_TYPE_UTF16, "utf16" } , {TB_CHARSET_TYPE_UTF32, "utf32" } @@ -122,10 +122,10 @@ tb_int_t xm_string_convert(lua_State* lua) tb_byte_t* dst_data = tb_malloc_bytes(dst_maxn); if (dst_data && dst_maxn && (dst_size = tb_charset_conv_data(fcharset->type, tcharset->type, (tb_byte_t const*)src_cstr, (tb_size_t)src_size, dst_data, dst_maxn)) >= 0 && dst_size < dst_maxn) { - dst_data[dst_size] = '\0'; - lua_pushstring(lua, (tb_char_t const*)dst_data); + lua_pushlstring(lua, (tb_char_t const *)dst_data, dst_size); } else lua_pushnil(lua); + tb_free(dst_data); } // ok |
