mirror of
https://github.com/neovim/neovim.git
synced 2025-09-16 08:18:17 +00:00
utf8_to_utf16: align with libuv
- take a size parameter - always NUL-terminate the result - return libuv error code - handle error in caller only (avoid redundant messages)53995a3825
4c945f4936
This commit is contained in:
@@ -2559,10 +2559,11 @@ static int do_more_prompt(int typed_char)
|
||||
#if defined(WIN32)
|
||||
void mch_errmsg(char *str)
|
||||
{
|
||||
assert(str != NULL);
|
||||
wchar_t *utf16str;
|
||||
int conversion_result = utf8_to_utf16((str), &utf16str);
|
||||
if (conversion_result != 0) {
|
||||
EMSG2("utf8_to_utf16 failed: %d", conversion_result);
|
||||
int r = utf8_to_utf16(str, -1, &utf16str);
|
||||
if (r != 0) {
|
||||
fprintf(stderr, "utf8_to_utf16 failed: %d", r);
|
||||
} else {
|
||||
fwprintf(stderr, L"%ls", utf16str);
|
||||
xfree(utf16str);
|
||||
@@ -2572,10 +2573,11 @@ void mch_errmsg(char *str)
|
||||
// Give a message. To be used when the UI is not initialized yet.
|
||||
void mch_msg(char *str)
|
||||
{
|
||||
assert(str != NULL);
|
||||
wchar_t *utf16str;
|
||||
int conversion_result = utf8_to_utf16((str), &utf16str);
|
||||
if (conversion_result != 0) {
|
||||
EMSG2("utf8_to_utf16 failed: %d", conversion_result);
|
||||
int r = utf8_to_utf16(str, -1, &utf16str);
|
||||
if (r != 0) {
|
||||
fprintf(stderr, "utf8_to_utf16 failed: %d", r);
|
||||
} else {
|
||||
wprintf(L"%ls", utf16str);
|
||||
xfree(utf16str);
|
||||
|
Reference in New Issue
Block a user