]>
Commit | Line | Data |
---|---|---|
e98ed9b1 ER |
1 | To: vim-dev@vim.org |
2 | Subject: Patch 7.1.158 (extra) | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=ISO-8859-1 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 7.1.158 (extra) | |
11 | Problem: Win32 console: When 'encoding' is "utf-8" and typing Alt-y the | |
12 | result is wrong. Win32 GUI: Alt-y results in "u" when 'encoding' | |
13 | is "cp1250" (Lukas Cerman) | |
14 | Solution: For utf-8 don't set the 7th bit in a byte, convert to the correct | |
15 | byte sequence. For cp1250, when conversion to 'encoding' results | |
16 | in the 7th bit not set, set the 7th bit after conversion. | |
17 | Files: src/os_win32.c, src/gui_w48.c | |
18 | ||
19 | ||
20 | *** ../vim-7.1.157/src/os_win32.c Mon Oct 1 20:33:45 2007 | |
21 | --- src/os_win32.c Sat Oct 27 17:35:04 2007 | |
22 | *************** | |
23 | *** 1521,1527 **** | |
24 | --- 1521,1532 ---- | |
25 | #endif | |
26 | ) | |
27 | { | |
28 | + #ifdef FEAT_MBYTE | |
29 | + n = (*mb_char2bytes)(typeahead[typeaheadlen] | 0x80, | |
30 | + typeahead + typeaheadlen); | |
31 | + #else | |
32 | typeahead[typeaheadlen] |= 0x80; | |
33 | + #endif | |
34 | modifiers &= ~MOD_MASK_ALT; | |
35 | } | |
36 | ||
37 | *** ../vim-7.1.157/src/gui_w48.c Sun Sep 30 14:00:41 2007 | |
38 | --- src/gui_w48.c Mon Oct 29 20:00:25 2007 | |
39 | *************** | |
40 | *** 486,495 **** | |
41 | ||
42 | /* | |
43 | * Convert Unicode character "ch" to bytes in "string[slen]". | |
44 | * Return the length. | |
45 | */ | |
46 | static int | |
47 | ! char_to_string(int ch, char_u *string, int slen) | |
48 | { | |
49 | int len; | |
50 | int i; | |
51 | --- 486,496 ---- | |
52 | ||
53 | /* | |
54 | * Convert Unicode character "ch" to bytes in "string[slen]". | |
55 | + * When "had_alt" is TRUE the ALT key was included in "ch". | |
56 | * Return the length. | |
57 | */ | |
58 | static int | |
59 | ! char_to_string(int ch, char_u *string, int slen, int had_alt) | |
60 | { | |
61 | int len; | |
62 | int i; | |
63 | *************** | |
64 | *** 522,529 **** | |
65 | --- 523,544 ---- | |
66 | * "enc_codepage" is non-zero use the standard Win32 function, | |
67 | * otherwise use our own conversion function (e.g., for UTF-8). */ | |
68 | if (enc_codepage > 0) | |
69 | + { | |
70 | len = WideCharToMultiByte(enc_codepage, 0, wstring, len, | |
71 | string, slen, 0, NULL); | |
72 | + /* If we had included the ALT key into the character but now the | |
73 | + * upper bit is no longer set, that probably means the conversion | |
74 | + * failed. Convert the original character and set the upper bit | |
75 | + * afterwards. */ | |
76 | + if (had_alt && len == 1 && ch >= 0x80 && string[0] < 0x80) | |
77 | + { | |
78 | + wstring[0] = ch & 0x7f; | |
79 | + len = WideCharToMultiByte(enc_codepage, 0, wstring, len, | |
80 | + string, slen, 0, NULL); | |
81 | + if (len == 1) /* safety check */ | |
82 | + string[0] |= 0x80; | |
83 | + } | |
84 | + } | |
85 | else | |
86 | { | |
87 | len = 1; | |
88 | *************** | |
89 | *** 573,579 **** | |
90 | char_u string[40]; | |
91 | int len = 0; | |
92 | ||
93 | ! len = char_to_string(ch, string, 40); | |
94 | if (len == 1 && string[0] == Ctrl_C && ctrl_c_interrupts) | |
95 | { | |
96 | trash_input_buf(); | |
97 | --- 588,594 ---- | |
98 | char_u string[40]; | |
99 | int len = 0; | |
100 | ||
101 | ! len = char_to_string(ch, string, 40, FALSE); | |
102 | if (len == 1 && string[0] == Ctrl_C && ctrl_c_interrupts) | |
103 | { | |
104 | trash_input_buf(); | |
105 | *************** | |
106 | *** 640,646 **** | |
107 | { | |
108 | /* Although the documentation isn't clear about it, we assume "ch" is | |
109 | * a Unicode character. */ | |
110 | ! len += char_to_string(ch, string + len, 40 - len); | |
111 | } | |
112 | ||
113 | add_to_input_buf(string, len); | |
114 | --- 655,661 ---- | |
115 | { | |
116 | /* Although the documentation isn't clear about it, we assume "ch" is | |
117 | * a Unicode character. */ | |
118 | ! len += char_to_string(ch, string + len, 40 - len, TRUE); | |
119 | } | |
120 | ||
121 | add_to_input_buf(string, len); | |
122 | *************** | |
123 | *** 1775,1781 **** | |
124 | int len; | |
125 | ||
126 | /* Handle "key" as a Unicode character. */ | |
127 | ! len = char_to_string(key, string, 40); | |
128 | add_to_input_buf(string, len); | |
129 | } | |
130 | break; | |
131 | --- 1790,1796 ---- | |
132 | int len; | |
133 | ||
134 | /* Handle "key" as a Unicode character. */ | |
135 | ! len = char_to_string(key, string, 40, FALSE); | |
136 | add_to_input_buf(string, len); | |
137 | } | |
138 | break; | |
139 | *** ../vim-7.1.157/src/version.c Tue Nov 20 12:30:31 2007 | |
140 | --- src/version.c Tue Nov 20 17:19:18 2007 | |
141 | *************** | |
142 | *** 668,669 **** | |
143 | --- 668,671 ---- | |
144 | { /* Add new patch number below this line */ | |
145 | + /**/ | |
146 | + 158, | |
147 | /**/ | |
148 | ||
149 | -- | |
150 | hundred-and-one symptoms of being an internet addict: | |
151 | 123. You ask the car dealer to install an extra cigarette lighter | |
152 | on your new car to power your notebook. | |
153 | ||
154 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
155 | /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
156 | \\\ download, build and distribute -- http://www.A-A-P.org /// | |
157 | \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |