summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorruki <[email protected]>2019-07-10 00:34:03 +0800
committerruki <[email protected]>2019-07-09 21:24:23 +0800
commit45c4a826ea4c6ce5967dd37b79ee668367cabcfd (patch)
tree8afff252903ae11ab9765e071683b65404d7012c /core/src
parent568844957830f65aab43c2d309afff64772655c7 (diff)
remove some unused funcs in ansi
Diffstat (limited to 'core/src')
-rw-r--r--core/src/xmake/machine.c4
-rw-r--r--core/src/xmake/string/convert.c23
-rw-r--r--core/src/xmake/winos/ansi.c101
-rw-r--r--core/src/xmake/winos/ansi.h10
4 files changed, 17 insertions, 121 deletions
diff --git a/core/src/xmake/machine.c b/core/src/xmake/machine.c
index f8b788aa7..77661a445 100644
--- a/core/src/xmake/machine.c
+++ b/core/src/xmake/machine.c
@@ -119,7 +119,6 @@ tb_int_t xm_hash_sha256(lua_State* lua);
// the windows functions
#ifdef TB_CONFIG_OS_WINDOWS
-tb_int_t xm_winos_mbstoutf8(lua_State* lua);
tb_int_t xm_winos_cp_info(lua_State* lua);
tb_int_t xm_winos_console_cp(lua_State* lua);
tb_int_t xm_winos_console_output_cp(lua_State* lua);
@@ -209,8 +208,7 @@ static luaL_Reg const g_os_functions[] =
#ifdef TB_CONFIG_OS_WINDOWS
static luaL_Reg const g_winos_functions[] =
{
- { "mbstoutf8", xm_winos_mbstoutf8 }
-, { "cp_info", xm_winos_cp_info }
+ { "cp_info", xm_winos_cp_info }
, { "console_cp", xm_winos_console_cp }
, { "console_output_cp", xm_winos_console_output_cp }
, { "oem_cp", xm_winos_oem_cp }
diff --git a/core/src/xmake/string/convert.c b/core/src/xmake/string/convert.c
index 693a605ee..a6edd5692 100644
--- a/core/src/xmake/string/convert.c
+++ b/core/src/xmake/string/convert.c
@@ -48,15 +48,20 @@ typedef struct __xm_charset_entry_t
// the charsets, @note: type & name is sorted
static xm_charset_entry_t g_charsets[] =
{
- {TB_CHARSET_TYPE_ASCII, "ascii" }
-, {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_UTF32, "utf32" }
-, {TB_CHARSET_TYPE_UTF8, "utf8" }
+ {TB_CHARSET_TYPE_ANSI, "ansi" }
+, {TB_CHARSET_TYPE_ASCII, "ascii" }
+, {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_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_BE, "utf32be" }
+, {TB_CHARSET_TYPE_UTF32 | TB_CHARSET_TYPE_LE, "utf32le" }
+, {TB_CHARSET_TYPE_UTF8, "utf8" }
};
/* //////////////////////////////////////////////////////////////////////////////////////
diff --git a/core/src/xmake/winos/ansi.c b/core/src/xmake/winos/ansi.c
index 8475af297..da4349d3c 100644
--- a/core/src/xmake/winos/ansi.c
+++ b/core/src/xmake/winos/ansi.c
@@ -22,8 +22,8 @@
/* //////////////////////////////////////////////////////////////////////////////////////
* trace
*/
-#define TB_TRACE_MODULE_NAME "ansi"
-#define TB_TRACE_MODULE_DEBUG (0)
+#define TB_TRACE_MODULE_NAME "ansi"
+#define TB_TRACE_MODULE_DEBUG (0)
/* //////////////////////////////////////////////////////////////////////////////////////
* includes
@@ -167,100 +167,3 @@ tb_int_t xm_winos_oem_cp(lua_State* lua)
return 1;
}
-tb_int_t xm_winos_mbstoutf8(lua_State* lua)
-{
- // check
- tb_assert_and_check_return_val(lua, 0);
-
- tb_int_t n = lua_gettop(lua);
- tb_check_return_val(n, 0);
- tb_int_t cp = 0;
- tb_int_t r_len = 0;
- lua_Integer lcp = luaL_optinteger(lua, 1, CP_ACP);
- luaL_argcheck(lua, cp >= 0 && cp < 65536, 1, "invalid code page");
- cp = (tb_int_t)lcp;
- for (tb_int_t i = 2; i <= n; i++)
- {
- size_t mbslen = 0;
- tb_char_t const* mbs = lua_tolstring(lua, i, &mbslen);
- tb_size_t utf8size = (mbslen + 1) * 4;
- tb_char_t* utf8 = tb_malloc_cstr(utf8size);
- tb_assert(mbs && utf8);
- utf8size = xm_mbstoutf8(utf8, mbs, utf8size, cp);
- tb_assert(utf8size < (mbslen + 1) * 4);
- lua_pushlstring(lua, utf8, utf8size);
- tb_free(utf8);
- r_len++;
- }
- return r_len;
-}
-
-tb_size_t xm_wcstoutf8(tb_char_t* s1, tb_wchar_t const* s2, tb_size_t n)
-{
- // check
- tb_assert_and_check_return_val(s1 && s2, 0);
-
- if (*s2 == 0)
- {
- if (n > 0) *s1 = 0;
- return 0;
- }
- tb_int_t size = WideCharToMultiByte(CP_UTF8, 0, s2, -1, s1, (tb_int_t)n, NULL, NULL);
- if (size > 0 && s1[size - 1] == 0) size--;
- return (tb_size_t)size;
-}
-
-tb_size_t xm_utf8towcs(tb_wchar_t* s1, tb_char_t const* s2, tb_size_t n)
-{
- // check
- tb_assert_and_check_return_val(s1 && s2, 0);
-
- if (*s2 == 0)
- {
- if (n > 0) *s1 = 0;
- return 0;
- }
- tb_int_t size = MultiByteToWideChar(CP_UTF8, 0, s2, -1, s1, (tb_int_t)n);
- if (size > 0 && s1[size - 1] == 0) size--;
- return (tb_size_t)size;
-}
-
-tb_size_t xm_mbstoutf8(tb_char_t* s1, tb_char_t const* s2, tb_size_t n, tb_int_t mbs_cp)
-{
- // check
- tb_assert_and_check_return_val(s1 && s2, 0);
-
- if (*s2 == 0)
- {
- if (n > 0) *s1 = 0;
- return 0;
- }
- tb_int_t u16buflen = MultiByteToWideChar(mbs_cp, 0, s2, -1, NULL, 0);
- tb_wchar_t* u16buf = tb_nalloc_type(u16buflen, tb_wchar_t);
- tb_assert(u16buf);
- u16buflen = MultiByteToWideChar(mbs_cp, 0, s2, -1, u16buf, u16buflen);
- tb_int_t size = WideCharToMultiByte(CP_UTF8, 0, u16buf, u16buflen, s1, (tb_int_t)n, NULL, NULL);
- tb_free(u16buf);
- if (size > 0 && s1[size - 1] == 0) size--;
- return (tb_size_t)size;
-}
-
-tb_size_t xm_utf8tombs(tb_char_t* s1, tb_char_t const* s2, tb_size_t n, tb_int_t mbs_cp)
-{
- // check
- tb_assert_and_check_return_val(s1 && s2, 0);
-
- if (*s2 == 0)
- {
- if (n > 0) *s1 = 0;
- return 0;
- }
- tb_int_t u16buflen = MultiByteToWideChar(CP_UTF8, 0, s2, -1, NULL, 0);
- tb_wchar_t* u16buf = tb_nalloc_type(u16buflen, tb_wchar_t);
- tb_assert(u16buf);
- u16buflen = MultiByteToWideChar(CP_UTF8, 0, s2, -1, u16buf, u16buflen);
- tb_int_t size = WideCharToMultiByte(mbs_cp, 0, u16buf, u16buflen, s1, (tb_int_t)n, NULL, NULL);
- tb_free(u16buf);
- if (size > 0 && s1[size - 1] == 0) size--;
- return (tb_size_t)size;
-}
diff --git a/core/src/xmake/winos/ansi.h b/core/src/xmake/winos/ansi.h
index d4f17a8b6..fe07d15ba 100644
--- a/core/src/xmake/winos/ansi.h
+++ b/core/src/xmake/winos/ansi.h
@@ -26,14 +26,4 @@
*/
#include "prefix.h"
-/* //////////////////////////////////////////////////////////////////////////////////////
- * interfaces
- */
-#ifdef TB_CONFIG_OS_WINDOWS
-tb_size_t xm_wcstoutf8(tb_char_t *s1, tb_wchar_t const *s2, tb_size_t n);
-tb_size_t xm_utf8towcs(tb_wchar_t *s1, tb_char_t const *s2, tb_size_t n);
-tb_size_t xm_mbstoutf8(tb_char_t *s1, tb_char_t const *s2, tb_size_t n, tb_int_t mbs_cp);
-tb_size_t xm_utf8tombs(tb_char_t *s1, tb_char_t const *s2, tb_size_t n, tb_int_t mbs_cp);
-#endif
-
#endif