Mercurial > vim
changeset 1443:69bcc0c891d7 v7.1.158
updated for version 7.1-158
author | vimboss |
---|---|
date | Tue, 20 Nov 2007 16:22:16 +0000 |
parents | bce7c73fd56d |
children | 215d6b2a1816 |
files | src/gui_w48.c src/os_win32.c src/version.c |
diffstat | 3 files changed, 26 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gui_w48.c +++ b/src/gui_w48.c @@ -486,10 +486,11 @@ gui_mch_start_blink(void) /* * Convert Unicode character "ch" to bytes in "string[slen]". + * When "had_alt" is TRUE the ALT key was included in "ch". * Return the length. */ static int -char_to_string(int ch, char_u *string, int slen) +char_to_string(int ch, char_u *string, int slen, int had_alt) { int len; int i; @@ -522,8 +523,22 @@ char_to_string(int ch, char_u *string, i * "enc_codepage" is non-zero use the standard Win32 function, * otherwise use our own conversion function (e.g., for UTF-8). */ if (enc_codepage > 0) + { len = WideCharToMultiByte(enc_codepage, 0, wstring, len, string, slen, 0, NULL); + /* If we had included the ALT key into the character but now the + * upper bit is no longer set, that probably means the conversion + * failed. Convert the original character and set the upper bit + * afterwards. */ + if (had_alt && len == 1 && ch >= 0x80 && string[0] < 0x80) + { + wstring[0] = ch & 0x7f; + len = WideCharToMultiByte(enc_codepage, 0, wstring, len, + string, slen, 0, NULL); + if (len == 1) /* safety check */ + string[0] |= 0x80; + } + } else { len = 1; @@ -573,7 +588,7 @@ char_to_string(int ch, char_u *string, i char_u string[40]; int len = 0; - len = char_to_string(ch, string, 40); + len = char_to_string(ch, string, 40, FALSE); if (len == 1 && string[0] == Ctrl_C && ctrl_c_interrupts) { trash_input_buf(); @@ -640,7 +655,7 @@ char_to_string(int ch, char_u *string, i { /* Although the documentation isn't clear about it, we assume "ch" is * a Unicode character. */ - len += char_to_string(ch, string + len, 40 - len); + len += char_to_string(ch, string + len, 40 - len, TRUE); } add_to_input_buf(string, len); @@ -1775,7 +1790,7 @@ process_message(void) int len; /* Handle "key" as a Unicode character. */ - len = char_to_string(key, string, 40); + len = char_to_string(key, string, 40, FALSE); add_to_input_buf(string, len); } break;