mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-29 18:48:09 +08:00
rename utf8_to_utf16 to tk_utf8_to_utf16, utf8_from_utf16 to tk_utf8_from_utf16
This commit is contained in:
parent
44d7e823e1
commit
17031959c3
@ -130,7 +130,7 @@ int WINAPI wWinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPWSTR lpcmdli
|
||||
int argc = 1;
|
||||
int32_t len = wcslen(lpcmdline) * 6;
|
||||
char* utf8_line = (char*)TKMEM_ALLOC(len);
|
||||
utf8_from_utf16(lpcmdline, utf8_line, len);
|
||||
tk_utf8_from_utf16(lpcmdline, utf8_line, len);
|
||||
char* argv[MAX_ARGV];
|
||||
str_init(&str, 1024);
|
||||
str_set(&str, utf8_line);
|
||||
|
@ -10,8 +10,8 @@
|
||||
char res_str[128];
|
||||
wchar_t res_wstr[128];
|
||||
|
||||
utf8_to_utf16(str, res_wstr, ARRAY_SIZE(res_wstr));
|
||||
utf8_from_utf16(wstr, res_str, ARRAY_SIZE(res_str));
|
||||
tk_utf8_to_utf16(str, res_wstr, ARRAY_SIZE(res_wstr));
|
||||
tk_utf8_from_utf16(wstr, res_str, ARRAY_SIZE(res_str));
|
||||
```
|
||||
|
||||
|
||||
@ -21,14 +21,14 @@
|
||||
|
||||
| 函数名称 | 说明 |
|
||||
| -------- | ------------ |
|
||||
| <a href="#utf8_utf8_from_utf16">utf8\_from\_utf16</a> | |
|
||||
| <a href="#utf8_utf8_from_utf16">utf8\_from\_utf16</a> | |
|
||||
| <a href="#tk_utf8_from_utf16">tk_\utf8\_from\_utf16</a> | |
|
||||
| <a href="#tk_utf8_to_utf16">tk\_utf8\_to\_utf16</a> | |
|
||||
#### utf8\_from\_utf16 函数
|
||||
-----------------------
|
||||
|
||||
* 函数功能:
|
||||
|
||||
> <p id="utf8_utf8_from_utf16">
|
||||
> <p id="tk_utf8_from_utf16">
|
||||
将wchar_t类型转换为char类型。
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
* 函数原型:
|
||||
|
||||
```
|
||||
char* utf8_from_utf16 (const wchar_t* str, const char* out, uint32_t size);
|
||||
char* tk_utf8_from_utf16 (const wchar_t* str, const char* out, uint32_t size);
|
||||
```
|
||||
|
||||
* 参数说明:
|
||||
@ -54,7 +54,7 @@ char* utf8_from_utf16 (const wchar_t* str, const char* out, uint32_t size);
|
||||
|
||||
* 函数功能:
|
||||
|
||||
> <p id="utf8_utf8_from_utf16">
|
||||
> <p id="tk_utf8_to_utf16">
|
||||
将char类型转换为wchar_t类型。
|
||||
|
||||
|
||||
@ -64,7 +64,7 @@ char* utf8_from_utf16 (const wchar_t* str, const char* out, uint32_t size);
|
||||
* 函数原型:
|
||||
|
||||
```
|
||||
wchar_t* utf8_from_utf16 (const char* str, const wchar_t* out, uint32_t size);
|
||||
wchar_t* tk_utf8_to_utf16 (const char* str, const wchar_t* out, uint32_t size);
|
||||
```
|
||||
|
||||
* 参数说明:
|
||||
|
@ -10,8 +10,8 @@ const wchar_t* wstr = L"hello";
|
||||
char res_str[128];
|
||||
wchar_t res_wstr[128];
|
||||
|
||||
utf8_to_utf16(str, res_wstr, ARRAY_SIZE(res_wstr));
|
||||
utf8_from_utf16(wstr, res_str, ARRAY_SIZE(res_str));
|
||||
tk_utf8_to_utf16(str, res_wstr, ARRAY_SIZE(res_wstr));
|
||||
tk_utf8_from_utf16(wstr, res_str, ARRAY_SIZE(res_str));
|
||||
```
|
||||
----------------------------------
|
||||
### 函数
|
||||
@ -19,19 +19,19 @@ utf8_from_utf16(wstr, res_str, ARRAY_SIZE(res_str));
|
||||
|
||||
| 函数名称 | 说明 |
|
||||
| -------- | ------------ |
|
||||
| <a href="#utf8_t_utf8_from_utf16">utf8\_from\_utf16</a> | 将wchar_t类型转换为char类型。 |
|
||||
| <a href="#utf8_t_utf8_from_utf16">utf8\_from\_utf16</a> | 将char类型转换为wchar_t类型。 |
|
||||
| <a href="#tk_utf8_from_utf16">tk\_utf8\_from\_utf16</a> | 将wchar_t类型转换为char类型。 |
|
||||
| <a href="#tk_utf8_to_utf16">tk\_utf8\_to\_utf16</a> | 将char类型转换为wchar_t类型。 |
|
||||
#### utf8\_from\_utf16 函数
|
||||
-----------------------
|
||||
|
||||
* 函数功能:
|
||||
|
||||
> <p id="utf8_t_utf8_from_utf16">将wchar_t类型转换为char类型。
|
||||
> <p id="tk_utf8_from_utf16">将wchar_t类型转换为char类型。
|
||||
|
||||
* 函数原型:
|
||||
|
||||
```
|
||||
char* utf8_from_utf16 (const wchar_t* str, const char* out, uint32_t size);
|
||||
char* tk_utf8_from_utf16 (const wchar_t* str, const char* out, uint32_t size);
|
||||
```
|
||||
|
||||
* 参数说明:
|
||||
@ -47,12 +47,12 @@ char* utf8_from_utf16 (const wchar_t* str, const char* out, uint32_t size);
|
||||
|
||||
* 函数功能:
|
||||
|
||||
> <p id="utf8_t_utf8_from_utf16">将char类型转换为wchar_t类型。
|
||||
> <p id="tk_utf8_to_utf16">将char类型转换为wchar_t类型。
|
||||
|
||||
* 函数原型:
|
||||
|
||||
```
|
||||
wchar_t* utf8_from_utf16 (const char* str, const wchar_t* out, uint32_t size);
|
||||
wchar_t* tk_utf8_to_utf16 (const char* str, const wchar_t* out, uint32_t size);
|
||||
```
|
||||
|
||||
* 参数说明:
|
||||
|
@ -1356,7 +1356,7 @@ static ret_t canvas_draw_fps(canvas_t* c) {
|
||||
lcd->fps_rect = r;
|
||||
tk_snprintf(fps, sizeof(fps), "%dfps", (int)(c->fps));
|
||||
|
||||
utf8_to_utf16(fps, wfps, strlen(fps) + 1);
|
||||
tk_utf8_to_utf16(fps, wfps, strlen(fps) + 1);
|
||||
canvas_fill_rect(c, r.x, r.y, r.w, r.h);
|
||||
canvas_draw_text(c, wfps, wcslen(wfps), r.x + 8, r.y + 8);
|
||||
} else {
|
||||
|
@ -98,7 +98,7 @@ static ret_t suggest_words_update(suggest_words_t* suggest_words, const uint8_t*
|
||||
memset(word, 0x00, sizeof(word));
|
||||
p16 = get_str(p16, word, ARRAY_SIZE(word) - 1);
|
||||
|
||||
utf8_from_utf16(word, sword, sizeof(sword));
|
||||
tk_utf8_from_utf16(word, sword, sizeof(sword));
|
||||
if (wbuffer_write_string(&wb, sword) != RET_OK) {
|
||||
break;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ static ret_t candidates_on_button_click(void* ctx, event_t* e) {
|
||||
wchar_t c = text->str[text->size - 1];
|
||||
return_value_if_fail(im != NULL && text->size > 0, RET_FAIL);
|
||||
|
||||
utf8_from_utf16(text->str, str, sizeof(str) - 1);
|
||||
tk_utf8_from_utf16(text->str, str, sizeof(str) - 1);
|
||||
if (input_method_commit_text(im, str) == RET_OK) {
|
||||
suggest_words_t* suggest_words = im->suggest_words;
|
||||
if (suggest_words && suggest_words_find(suggest_words, c) == RET_OK) {
|
||||
|
@ -45,7 +45,7 @@ rich_text_node_t* rich_text_text_create_with_len(rich_text_font_t* font, const c
|
||||
node->u.text.text = (wchar_t*)TKMEM_ALLOC(sizeof(wchar_t) * (len + 1));
|
||||
goto_error_if_fail(node->u.text.text != NULL);
|
||||
|
||||
utf8_to_utf16(text, node->u.text.text, len + 1);
|
||||
tk_utf8_to_utf16(text, node->u.text.text, len + 1);
|
||||
|
||||
return node;
|
||||
error:
|
||||
|
@ -533,7 +533,7 @@ ret_t text_selector_append_option(widget_t* widget, int32_t value, const char* t
|
||||
memset(option, 0x00, size);
|
||||
|
||||
option->value = value;
|
||||
utf8_to_utf16(text, option->text, strlen(text) + 1);
|
||||
tk_utf8_to_utf16(text, option->text, strlen(text) + 1);
|
||||
|
||||
if (text_selector->option_items != NULL) {
|
||||
iter = text_selector->option_items;
|
||||
|
@ -51,7 +51,7 @@ static ret_t input_engine_pinyin_add_candidate(input_engine_t* engine, wbuffer_t
|
||||
}
|
||||
wstr[i] = 0;
|
||||
|
||||
utf8_from_utf16(wstr, str, sizeof(str) - 1);
|
||||
tk_utf8_from_utf16(wstr, str, sizeof(str) - 1);
|
||||
|
||||
if ((wb->cursor + strlen(str) + 1) >= wb->capacity) {
|
||||
return RET_FAIL;
|
||||
|
@ -211,7 +211,7 @@ float_t lcd_vgcanvas_measure_text(lcd_t* lcd, const wchar_t* str, uint32_t nr) {
|
||||
wcsncpy(temp, str, nr);
|
||||
temp[nr] = 0;
|
||||
|
||||
utf8_from_utf16(temp, text, sizeof(text) - 1);
|
||||
tk_utf8_from_utf16(temp, text, sizeof(text) - 1);
|
||||
|
||||
vgcanvas_set_font(canvas, lcd->font_name);
|
||||
vgcanvas_set_font_size(canvas, lcd->font_size);
|
||||
@ -231,7 +231,7 @@ static ret_t lcd_vgcanvas_draw_text(lcd_t* lcd, const wchar_t* str, uint32_t nr,
|
||||
wcsncpy(temp, str, nr);
|
||||
temp[nr] = 0;
|
||||
|
||||
utf8_from_utf16(temp, text, sizeof(text) - 1);
|
||||
tk_utf8_from_utf16(temp, text, sizeof(text) - 1);
|
||||
|
||||
vgcanvas_set_font(canvas, lcd->font_name);
|
||||
vgcanvas_set_font_size(canvas, lcd->font_size);
|
||||
|
@ -85,7 +85,7 @@ ret_t fs_os_dir_read(fs_dir_t* dir, fs_item_t* item) {
|
||||
|
||||
len = wcslen(ent->d_name) * 2 + 1;
|
||||
name = (char*)TKMEM_ALLOC(len);
|
||||
utf8_from_utf16(ent->d_name, name, len);
|
||||
tk_utf8_from_utf16(ent->d_name, name, len);
|
||||
tk_strncpy(item->name, name, MAX_PATH);
|
||||
TKMEM_FREE(name);
|
||||
#else
|
||||
@ -136,11 +136,11 @@ fs_file_t* fs_os_open_file(fs_t* fs, const char* name, const char* mode) {
|
||||
|
||||
len = strlen(name) + 1;
|
||||
w_name = (wchar_t*)TKMEM_ALLOC(len * 2);
|
||||
utf8_to_utf16(name, w_name, len);
|
||||
tk_utf8_to_utf16(name, w_name, len);
|
||||
|
||||
len = strlen(mode) + 1;
|
||||
w_mode = (wchar_t*)TKMEM_ALLOC(len * 2);
|
||||
utf8_to_utf16(mode, w_mode, len);
|
||||
tk_utf8_to_utf16(mode, w_mode, len);
|
||||
|
||||
file = fs_file_create(_wfopen(w_name, w_mode));
|
||||
TKMEM_FREE(w_name);
|
||||
@ -161,7 +161,7 @@ ret_t fs_os_remove_file(fs_t* fs, const char* name) {
|
||||
|
||||
len = strlen(name) + 1;
|
||||
w_name = (wchar_t*)TKMEM_ALLOC(len * 2);
|
||||
utf8_to_utf16(name, w_name, len);
|
||||
tk_utf8_to_utf16(name, w_name, len);
|
||||
|
||||
_wunlink(w_name);
|
||||
TKMEM_FREE(w_name);
|
||||
@ -183,7 +183,7 @@ bool_t fs_os_file_exist(fs_t* fs, const char* name) {
|
||||
|
||||
len = strlen(name) + 1;
|
||||
w_name = (wchar_t*)TKMEM_ALLOC(len * 2);
|
||||
utf8_to_utf16(name, w_name, len);
|
||||
tk_utf8_to_utf16(name, w_name, len);
|
||||
|
||||
rtn = (_wstat(w_name, &st) == 0 && st.st_mode & S_IFREG);
|
||||
TKMEM_FREE(w_name);
|
||||
@ -206,11 +206,11 @@ bool_t fs_os_file_rename(fs_t* fs, const char* name, const char* new_name) {
|
||||
|
||||
len = strlen(name) + 1;
|
||||
w_name = (wchar_t*)TKMEM_ALLOC(len * 2);
|
||||
utf8_to_utf16(name, w_name, len);
|
||||
tk_utf8_to_utf16(name, w_name, len);
|
||||
|
||||
len = strlen(new_name) + 1;
|
||||
w_new_name = (wchar_t*)TKMEM_ALLOC(len * 2);
|
||||
utf8_to_utf16(new_name, w_new_name, len);
|
||||
tk_utf8_to_utf16(new_name, w_new_name, len);
|
||||
|
||||
rtn = _wrename(w_name, w_new_name) == 0;
|
||||
TKMEM_FREE(w_name);
|
||||
@ -248,7 +248,7 @@ fs_dir_t* fs_os_open_dir(fs_t* fs, const char* name) {
|
||||
|
||||
len = strlen(name) + 1;
|
||||
w_name = (wchar_t*)TKMEM_ALLOC(len * 2);
|
||||
utf8_to_utf16(name, w_name, len);
|
||||
tk_utf8_to_utf16(name, w_name, len);
|
||||
|
||||
pDir = fs_dir_create(opendir(w_name));
|
||||
TKMEM_FREE(w_name);
|
||||
@ -274,7 +274,7 @@ bool_t fs_os_dir_exist(fs_t* fs, const char* name) {
|
||||
|
||||
len = strlen(name) + 1;
|
||||
w_name = (wchar_t*)TKMEM_ALLOC(len * 2);
|
||||
utf8_to_utf16(name, w_name, len);
|
||||
tk_utf8_to_utf16(name, w_name, len);
|
||||
|
||||
rtn = (_wstat(w_name, &st) == 0 && st.st_mode & S_IFDIR);
|
||||
TKMEM_FREE(w_name);
|
||||
@ -305,7 +305,7 @@ int32_t fs_os_get_file_size(fs_t* fs, const char* name) {
|
||||
|
||||
len = strlen(name) + 1;
|
||||
w_name = (wchar_t*)TKMEM_ALLOC(len * 2);
|
||||
utf8_to_utf16(name, w_name, len);
|
||||
tk_utf8_to_utf16(name, w_name, len);
|
||||
|
||||
int n = _wstat(w_name, &st);
|
||||
rtn = n == 0;
|
||||
|
@ -271,7 +271,7 @@ ret_t str_from_wstr(str_t* str, const wchar_t* wstr) {
|
||||
return_value_if_fail(str_extend(str, size + 1) == RET_OK, RET_OOM);
|
||||
|
||||
if (size > 0) {
|
||||
utf8_from_utf16(wstr, str->str, size);
|
||||
tk_utf8_from_utf16(wstr, str->str, size);
|
||||
str->size = strlen(str->str);
|
||||
} else {
|
||||
str_set(str, "");
|
||||
|
@ -262,13 +262,13 @@ err_out:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char* utf8_from_utf16(const wchar_t* str, char* out, uint32_t size) {
|
||||
char* tk_utf8_from_utf16(const wchar_t* str, char* out, uint32_t size) {
|
||||
return_value_if_fail(str != NULL && out != NULL, NULL);
|
||||
|
||||
return utf16_to_utf8(str, wcslen(str), out, size);
|
||||
}
|
||||
|
||||
wchar_t* utf8_to_utf16(const char* str, wchar_t* out, uint32_t size) {
|
||||
wchar_t* tk_utf8_to_utf16(const char* str, wchar_t* out, uint32_t size) {
|
||||
uint32_t i = 0;
|
||||
const char* p = str;
|
||||
const char* next = NULL;
|
||||
|
@ -39,13 +39,13 @@ BEGIN_C_DECLS
|
||||
* char res_str[128];
|
||||
* wchar_t res_wstr[128];
|
||||
|
||||
* utf8_to_utf16(str, res_wstr, ARRAY_SIZE(res_wstr));
|
||||
* utf8_from_utf16(wstr, res_str, ARRAY_SIZE(res_str));
|
||||
* tk_utf8_to_utf16(str, res_wstr, ARRAY_SIZE(res_wstr));
|
||||
* tk_utf8_from_utf16(wstr, res_str, ARRAY_SIZE(res_str));
|
||||
* ```
|
||||
*/
|
||||
|
||||
/**
|
||||
* @method utf8_from_utf16
|
||||
* @method tk_utf8_from_utf16
|
||||
*
|
||||
* 将wchar_t类型转换为char类型。
|
||||
*
|
||||
@ -55,10 +55,10 @@ BEGIN_C_DECLS
|
||||
*
|
||||
* @return {char*} 值。
|
||||
*/
|
||||
char* utf8_from_utf16(const wchar_t* str, char* out, uint32_t size);
|
||||
char* tk_utf8_from_utf16(const wchar_t* str, char* out, uint32_t size);
|
||||
|
||||
/**
|
||||
* @method utf8_from_utf16
|
||||
* @method tk_utf8_to_utf16
|
||||
*
|
||||
* 将char类型转换为wchar_t类型。
|
||||
*
|
||||
@ -68,7 +68,7 @@ char* utf8_from_utf16(const wchar_t* str, char* out, uint32_t size);
|
||||
*
|
||||
* @return {wchar_t*} 值。
|
||||
*/
|
||||
wchar_t* utf8_to_utf16(const char* str, wchar_t* out, uint32_t size);
|
||||
wchar_t* tk_utf8_to_utf16(const char* str, wchar_t* out, uint32_t size);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
|
@ -630,7 +630,7 @@ int tk_watoi(const wchar_t* str) {
|
||||
char num[TK_NUM_MAX_LEN + 1] = {0};
|
||||
return_value_if_fail(str != NULL, 0);
|
||||
|
||||
utf8_from_utf16(str, num, TK_NUM_MAX_LEN);
|
||||
tk_utf8_from_utf16(str, num, TK_NUM_MAX_LEN);
|
||||
|
||||
return tk_atoi(num);
|
||||
}
|
||||
@ -647,7 +647,7 @@ double tk_watof(const wchar_t* str) {
|
||||
char num[TK_NUM_MAX_LEN + 1] = {0};
|
||||
return_value_if_fail(str != NULL, 0);
|
||||
|
||||
utf8_from_utf16(str, num, TK_NUM_MAX_LEN);
|
||||
tk_utf8_from_utf16(str, num, TK_NUM_MAX_LEN);
|
||||
|
||||
return tk_atof(num);
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ ret_t wstr_set_utf8(wstr_t* str, const char* text) {
|
||||
return_value_if_fail(str != NULL && text != NULL, RET_BAD_PARAMS);
|
||||
return_value_if_fail(wstr_extend(str, strlen(text) + 2) == RET_OK, RET_OOM);
|
||||
|
||||
utf8_to_utf16(text, str->str, str->capacity - 1);
|
||||
tk_utf8_to_utf16(text, str->str, str->capacity - 1);
|
||||
str->size = wcslen(str->str);
|
||||
|
||||
return RET_OK;
|
||||
@ -165,7 +165,7 @@ ret_t wstr_set_utf8(wstr_t* str, const char* text) {
|
||||
|
||||
ret_t wstr_get_utf8(wstr_t* str, char* text, uint32_t size) {
|
||||
return_value_if_fail(str != NULL && text != NULL, RET_BAD_PARAMS);
|
||||
utf8_from_utf16(str->str, text, size);
|
||||
tk_utf8_from_utf16(str->str, text, size);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
@ -248,7 +248,7 @@ ret_t wstr_push_int(wstr_t* str, const char* format, int32_t value) {
|
||||
return_value_if_fail(str != NULL && format != NULL, RET_BAD_PARAMS);
|
||||
|
||||
tk_snprintf(buff, TK_NUM_MAX_LEN, format, value);
|
||||
utf8_to_utf16(buff, s, TK_NUM_MAX_LEN);
|
||||
tk_utf8_to_utf16(buff, s, TK_NUM_MAX_LEN);
|
||||
|
||||
return wstr_append_with_len(str, s, wcslen(s));
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ static wchar_t* digit_clock_translate_wday(wchar_t* str, uint32_t size, uint32_t
|
||||
};
|
||||
|
||||
const char* utf8 = locale_info_tr(locale_info(), wdays[wday]);
|
||||
return utf8_to_utf16(utf8, str, size);
|
||||
return tk_utf8_to_utf16(utf8, str, size);
|
||||
}
|
||||
|
||||
static wchar_t* digit_clock_translate_month(wchar_t* str, uint32_t size, uint32_t month) {
|
||||
@ -56,7 +56,7 @@ static wchar_t* digit_clock_translate_month(wchar_t* str, uint32_t size, uint32_
|
||||
"Jul", "Aug", "Sept", "Oct", "Nov", "Dec"};
|
||||
|
||||
const char* utf8 = locale_info_tr(locale_info(), months[month - 1]);
|
||||
return utf8_to_utf16(utf8, str, size);
|
||||
return tk_utf8_to_utf16(utf8, str, size);
|
||||
}
|
||||
|
||||
ret_t digit_clock_format_time(widget_t* widget, const char* format, date_time_t* dt) {
|
||||
|
@ -197,7 +197,7 @@ ret_t edit_input_char(widget_t* widget, wchar_t c) {
|
||||
static ret_t edit_commit_str(widget_t* widget, const char* str) {
|
||||
uint32_t i = 0;
|
||||
wchar_t wstr[32];
|
||||
utf8_to_utf16(str, wstr, ARRAY_SIZE(wstr));
|
||||
tk_utf8_to_utf16(str, wstr, ARRAY_SIZE(wstr));
|
||||
|
||||
while (wstr[i]) {
|
||||
edit_input_char(widget, wstr[i]);
|
||||
|
@ -58,7 +58,7 @@ using std::string;
|
||||
void assert_str_eq(const wchar_t* wstr, const char* utf8) {
|
||||
char str[256];
|
||||
|
||||
utf8_from_utf16(wstr, str, sizeof(str));
|
||||
tk_utf8_from_utf16(wstr, str, sizeof(str));
|
||||
ASSERT_EQ(string(str), string(utf8));
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ TEST(TextSelector, range) {
|
||||
for (i = 0; i < n; i++) {
|
||||
text_selector_option_t* iter = text_selector_get_option(w, i);
|
||||
ASSERT_EQ(iter->value, i + 1);
|
||||
utf8_from_utf16(iter->text, text1, sizeof(text1) - 1);
|
||||
tk_utf8_from_utf16(iter->text, text1, sizeof(text1) - 1);
|
||||
tk_snprintf(text2, sizeof(text2) - 1, "%d", i + 1);
|
||||
ASSERT_STREQ(text1, text2);
|
||||
}
|
||||
@ -171,7 +171,7 @@ TEST(TextSelector, range_format) {
|
||||
for (i = 0; i < n; i++) {
|
||||
text_selector_option_t* iter = text_selector_get_option(w, i);
|
||||
ASSERT_EQ(iter->value, i + 1);
|
||||
utf8_from_utf16(iter->text, text1, sizeof(text1) - 1);
|
||||
tk_utf8_from_utf16(iter->text, text1, sizeof(text1) - 1);
|
||||
tk_snprintf(text2, sizeof(text2) - 1, "%4d", i + 1);
|
||||
ASSERT_STREQ(text1, text2);
|
||||
}
|
||||
@ -193,7 +193,7 @@ TEST(TextSelector, range_format2) {
|
||||
for (i = 0; i < n; i++) {
|
||||
text_selector_option_t* iter = text_selector_get_option(w, i);
|
||||
ASSERT_EQ(iter->value, i + 1);
|
||||
utf8_from_utf16(iter->text, text1, sizeof(text1) - 1);
|
||||
tk_utf8_from_utf16(iter->text, text1, sizeof(text1) - 1);
|
||||
tk_snprintf(text2, sizeof(text2) - 1, "item%4X", i + 1);
|
||||
ASSERT_STREQ(text1, text2);
|
||||
}
|
||||
|
@ -7,8 +7,8 @@ TEST(Utf8, ascii) {
|
||||
char res_str[128];
|
||||
wchar_t res_wstr[128];
|
||||
|
||||
ASSERT_EQ(wcscmp(utf8_to_utf16(str, res_wstr, ARRAY_SIZE(res_wstr)), wstr), 0);
|
||||
ASSERT_EQ(strcmp(utf8_from_utf16(wstr, res_str, ARRAY_SIZE(res_str)), str), 0);
|
||||
ASSERT_EQ(wcscmp(tk_utf8_to_utf16(str, res_wstr, ARRAY_SIZE(res_wstr)), wstr), 0);
|
||||
ASSERT_EQ(strcmp(tk_utf8_from_utf16(wstr, res_str, ARRAY_SIZE(res_str)), str), 0);
|
||||
}
|
||||
|
||||
TEST(Utf8, chinese) {
|
||||
@ -17,6 +17,6 @@ TEST(Utf8, chinese) {
|
||||
char res_str[128];
|
||||
wchar_t res_wstr[128];
|
||||
|
||||
ASSERT_EQ(wcscmp(utf8_to_utf16(str, res_wstr, ARRAY_SIZE(res_wstr)), wstr), 0);
|
||||
ASSERT_EQ(strcmp(utf8_from_utf16(wstr, res_str, ARRAY_SIZE(res_str)), str), 0);
|
||||
ASSERT_EQ(wcscmp(tk_utf8_to_utf16(str, res_wstr, ARRAY_SIZE(res_wstr)), wstr), 0);
|
||||
ASSERT_EQ(strcmp(tk_utf8_from_utf16(wstr, res_str, ARRAY_SIZE(res_str)), str), 0);
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ uint32_t font_gen_buff(font_t* font, uint16_t font_size, const char* str, uint8_
|
||||
font_vmetrics_t vmetrics = font_get_vmetrics(font, font_size);
|
||||
font_bitmap_header_t* header = (font_bitmap_header_t*)output_buff;
|
||||
|
||||
utf8_to_utf16(str, wstr, MAX_CHARS);
|
||||
tk_utf8_to_utf16(str, wstr, MAX_CHARS);
|
||||
size = wcslen(wstr);
|
||||
|
||||
qsort(wstr, size, sizeof(wchar_t), char_cmp);
|
||||
|
@ -16014,7 +16014,7 @@
|
||||
],
|
||||
"annotation": {},
|
||||
"desc": "将wchar_t类型转换为char类型。",
|
||||
"name": "utf8_from_utf16",
|
||||
"name": "tk_utf8_from_utf16",
|
||||
"return": {
|
||||
"type": "char*",
|
||||
"desc": "值。"
|
||||
@ -16040,7 +16040,7 @@
|
||||
],
|
||||
"annotation": {},
|
||||
"desc": "将char类型转换为wchar_t类型。",
|
||||
"name": "utf8_from_utf16",
|
||||
"name": "tk_utf8_from_utf16",
|
||||
"return": {
|
||||
"type": "wchar_t*",
|
||||
"desc": "值。"
|
||||
@ -16050,7 +16050,7 @@
|
||||
"events": [],
|
||||
"properties": [],
|
||||
"header": "tkc/utf8.h",
|
||||
"desc": "wchar_t和char类型转换接口。\n\n示例:\n\n```c\nconst char* str = \"hello\";\nconst wchar_t* wstr = L\"hello\";\nchar res_str[128];\nwchar_t res_wstr[128];\n\nutf8_to_utf16(str, res_wstr, ARRAY_SIZE(res_wstr));\nutf8_from_utf16(wstr, res_str, ARRAY_SIZE(res_str));\n```",
|
||||
"desc": "wchar_t和char类型转换接口。\n\n示例:\n\n```c\nconst char* str = \"hello\";\nconst wchar_t* wstr = L\"hello\";\nchar res_str[128];\nwchar_t res_wstr[128];\n\ntk_utf8_to_utf16(str, res_wstr, ARRAY_SIZE(res_wstr));\ntk_utf8_from_utf16(wstr, res_str, ARRAY_SIZE(res_str));\n```",
|
||||
"name": "utf8_t",
|
||||
"annotation": {
|
||||
"fake": true
|
||||
|
Loading…
Reference in New Issue
Block a user