summaryrefslogtreecommitdiffstats
path: root/source/ap/vim/patches/7.2.049
diff options
context:
space:
mode:
Diffstat (limited to 'source/ap/vim/patches/7.2.049')
-rw-r--r--source/ap/vim/patches/7.2.0491193
1 files changed, 1193 insertions, 0 deletions
diff --git a/source/ap/vim/patches/7.2.049 b/source/ap/vim/patches/7.2.049
new file mode 100644
index 000000000..0f6efa87f
--- /dev/null
+++ b/source/ap/vim/patches/7.2.049
@@ -0,0 +1,1193 @@
+To: vim-dev@vim.org
+Subject: Patch 7.2.049 (extra)
+Fcc: outbox
+From: Bram Moolenaar <Bram@moolenaar.net>
+Mime-Version: 1.0
+Content-Type: text/plain; charset=ISO-8859-1
+Content-Transfer-Encoding: 8bit
+------------
+
+Patch 7.2.049 (extra)
+Problem: Win32: the clipboard doesn't support UTF-16.
+Solution: Change UCS-2 support to UTF-16 support. (Jia Yanwei)
+Files: src/gui_w32.c, src/gui_w48.c, src/mbyte.c, src/misc1.c,
+ src/os_mswin.c, src/os_win32.c, src/proto/os_mswin.pro
+
+
+*** ../vim-7.2.048/src/gui_w32.c Tue Jun 24 23:46:14 2008
+--- src/gui_w32.c Thu Nov 20 16:47:10 2008
+***************
+*** 992,998 ****
+ SendMessage(lpdi->hdr.hwndFrom, TTM_SETMAXTIPWIDTH,
+ 0, 500);
+
+! tt_text = enc_to_ucs2(str, NULL);
+ lpdi->lpszText = tt_text;
+ /* can't show tooltip if failed */
+ }
+--- 992,998 ----
+ SendMessage(lpdi->hdr.hwndFrom, TTM_SETMAXTIPWIDTH,
+ 0, 500);
+
+! tt_text = enc_to_utf16(str, NULL);
+ lpdi->lpszText = tt_text;
+ /* can't show tooltip if failed */
+ }
+***************
+*** 1935,1941 ****
+ if (buf == NULL)
+ return NULL;
+
+! convbuf = ucs2_to_enc(buf, lenp);
+ pImmReleaseContext(hwnd, hIMC);
+ vim_free(buf);
+ return convbuf;
+--- 1935,1941 ----
+ if (buf == NULL)
+ return NULL;
+
+! convbuf = utf16_to_enc(buf, lenp);
+ pImmReleaseContext(hwnd, hIMC);
+ vim_free(buf);
+ return convbuf;
+***************
+*** 2566,2572 ****
+ {
+ /* 'encoding' differs from active codepage: convert menu name
+ * and use wide function */
+! wn = enc_to_ucs2(menu->name, NULL);
+ if (wn != NULL)
+ {
+ MENUITEMINFOW infow;
+--- 2566,2572 ----
+ {
+ /* 'encoding' differs from active codepage: convert menu name
+ * and use wide function */
+! wn = enc_to_utf16(menu->name, NULL);
+ if (wn != NULL)
+ {
+ MENUITEMINFOW infow;
+***************
+*** 2728,2734 ****
+ {
+ /* 'encoding' differs from active codepage: convert menu item name
+ * and use wide function */
+! wn = enc_to_ucs2(menu->name, NULL);
+ if (wn != NULL)
+ {
+ n = InsertMenuW(parent->submenu_id, (UINT)idx,
+--- 2728,2734 ----
+ {
+ /* 'encoding' differs from active codepage: convert menu item name
+ * and use wide function */
+! wn = enc_to_utf16(menu->name, NULL);
+ if (wn != NULL)
+ {
+ n = InsertMenuW(parent->submenu_id, (UINT)idx,
+***************
+*** 3570,3576 ****
+ if (enc_codepage == 0 && (int)GetACP() != enc_codepage)
+ {
+ /* Not a codepage, use our own conversion function. */
+! wn = enc_to_ucs2(lpAnsiIn, NULL);
+ if (wn != NULL)
+ {
+ wcscpy(lpWCStr, wn);
+--- 3570,3576 ----
+ if (enc_codepage == 0 && (int)GetACP() != enc_codepage)
+ {
+ /* Not a codepage, use our own conversion function. */
+! wn = enc_to_utf16(lpAnsiIn, NULL);
+ if (wn != NULL)
+ {
+ wcscpy(lpWCStr, wn);
+*** ../vim-7.2.048/src/gui_w48.c Wed Nov 12 13:35:31 2008
+--- src/gui_w48.c Thu Nov 20 16:42:32 2008
+***************
+*** 547,553 ****
+ else
+ {
+ len = 1;
+! ws = ucs2_to_enc(wstring, &len);
+ if (ws == NULL)
+ len = 0;
+ else
+--- 547,553 ----
+ else
+ {
+ len = 1;
+! ws = utf16_to_enc(wstring, &len);
+ if (ws == NULL)
+ len = 0;
+ else
+***************
+*** 2128,2134 ****
+ {
+ /* 'encoding' differs from active codepage: convert text and use wide
+ * function */
+! wstr = enc_to_ucs2(str, &wlen);
+ if (wstr != NULL)
+ {
+ n = GetTextExtentPointW(hdc, wstr, wlen, &size);
+--- 2128,2134 ----
+ {
+ /* 'encoding' differs from active codepage: convert text and use wide
+ * function */
+! wstr = enc_to_utf16(str, &wlen);
+ if (wstr != NULL)
+ {
+ n = GetTextExtentPointW(hdc, wstr, wlen, &size);
+***************
+*** 2252,2258 ****
+ {
+ /* 'encoding' differs from active codepage: convert menu name
+ * and use wide function */
+! wn = enc_to_ucs2(item_text, NULL);
+ if (wn != NULL)
+ {
+ MENUITEMINFOW infow;
+--- 2252,2258 ----
+ {
+ /* 'encoding' differs from active codepage: convert menu name
+ * and use wide function */
+! wn = enc_to_utf16(item_text, NULL);
+ if (wn != NULL)
+ {
+ MENUITEMINFOW infow;
+***************
+*** 2422,2428 ****
+ if (use_unicode)
+ {
+ /* Need to go through Unicode. */
+! wstr = enc_to_ucs2(NameBuff, NULL);
+ if (wstr != NULL)
+ {
+ TCITEMW tiw;
+--- 2422,2428 ----
+ if (use_unicode)
+ {
+ /* Need to go through Unicode. */
+! wstr = enc_to_utf16(NameBuff, NULL);
+ if (wstr != NULL)
+ {
+ TCITEMW tiw;
+***************
+*** 2521,2528 ****
+ WCHAR *wbuf;
+ int n;
+
+! /* Convert the title from 'encoding' to ucs2. */
+! wbuf = (WCHAR *)enc_to_ucs2((char_u *)title, NULL);
+ if (wbuf != NULL)
+ {
+ n = SetWindowTextW(hwnd, wbuf);
+--- 2521,2528 ----
+ WCHAR *wbuf;
+ int n;
+
+! /* Convert the title from 'encoding' to UTF-16. */
+! wbuf = (WCHAR *)enc_to_utf16((char_u *)title, NULL);
+ if (wbuf != NULL)
+ {
+ n = SetWindowTextW(hwnd, wbuf);
+***************
+*** 3222,3228 ****
+ char_u *initdir,
+ char_u *filter)
+ {
+! /* We always use the wide function. This means enc_to_ucs2() must work,
+ * otherwise it fails miserably! */
+ OPENFILENAMEW fileStruct;
+ WCHAR fileBuf[MAXPATHL];
+--- 3222,3228 ----
+ char_u *initdir,
+ char_u *filter)
+ {
+! /* We always use the wide function. This means enc_to_utf16() must work,
+ * otherwise it fails miserably! */
+ OPENFILENAMEW fileStruct;
+ WCHAR fileBuf[MAXPATHL];
+***************
+*** 3238,3244 ****
+ fileBuf[0] = NUL;
+ else
+ {
+! wp = enc_to_ucs2(dflt, NULL);
+ if (wp == NULL)
+ fileBuf[0] = NUL;
+ else
+--- 3238,3244 ----
+ fileBuf[0] = NUL;
+ else
+ {
+! wp = enc_to_utf16(dflt, NULL);
+ if (wp == NULL)
+ fileBuf[0] = NUL;
+ else
+***************
+*** 3263,3273 ****
+ #endif
+
+ if (title != NULL)
+! titlep = enc_to_ucs2(title, NULL);
+ fileStruct.lpstrTitle = titlep;
+
+ if (ext != NULL)
+! extp = enc_to_ucs2(ext, NULL);
+ fileStruct.lpstrDefExt = extp;
+
+ fileStruct.lpstrFile = fileBuf;
+--- 3263,3273 ----
+ #endif
+
+ if (title != NULL)
+! titlep = enc_to_utf16(title, NULL);
+ fileStruct.lpstrTitle = titlep;
+
+ if (ext != NULL)
+! extp = enc_to_utf16(ext, NULL);
+ fileStruct.lpstrDefExt = extp;
+
+ fileStruct.lpstrFile = fileBuf;
+***************
+*** 3278,3284 ****
+ if (initdir != NULL && *initdir != NUL)
+ {
+ /* Must have backslashes here, no matter what 'shellslash' says */
+! initdirp = enc_to_ucs2(initdir, NULL);
+ if (initdirp != NULL)
+ {
+ for (wp = initdirp; *wp != NUL; ++wp)
+--- 3278,3284 ----
+ if (initdir != NULL && *initdir != NUL)
+ {
+ /* Must have backslashes here, no matter what 'shellslash' says */
+! initdirp = enc_to_utf16(initdir, NULL);
+ if (initdirp != NULL)
+ {
+ for (wp = initdirp; *wp != NUL; ++wp)
+***************
+*** 3318,3324 ****
+ vim_free(extp);
+
+ /* Convert from UCS2 to 'encoding'. */
+! p = ucs2_to_enc(fileBuf, NULL);
+ if (p != NULL)
+ /* when out of memory we get garbage for non-ASCII chars */
+ STRCPY(fileBuf, p);
+--- 3318,3324 ----
+ vim_free(extp);
+
+ /* Convert from UCS2 to 'encoding'. */
+! p = utf16_to_enc(fileBuf, NULL);
+ if (p != NULL)
+ /* when out of memory we get garbage for non-ASCII chars */
+ STRCPY(fileBuf, p);
+***************
+*** 3518,3524 ****
+ {
+ #ifdef FEAT_MBYTE
+ if (DragQueryFileW(hDrop, i, wszFile, BUFPATHLEN) > 0)
+! fnames[i] = ucs2_to_enc(wszFile, NULL);
+ else
+ #endif
+ {
+--- 3518,3524 ----
+ {
+ #ifdef FEAT_MBYTE
+ if (DragQueryFileW(hDrop, i, wszFile, BUFPATHLEN) > 0)
+! fnames[i] = utf16_to_enc(wszFile, NULL);
+ else
+ #endif
+ {
+*** ../vim-7.2.048/src/mbyte.c Thu Nov 20 11:55:53 2008
+--- src/mbyte.c Thu Nov 20 16:47:41 2008
+***************
+*** 6101,6107 ****
+
+ /* 1. codepage/UTF-8 -> ucs-2. */
+ if (vcp->vc_cpfrom == 0)
+! tmp_len = utf8_to_ucs2(ptr, len, NULL, NULL);
+ else
+ tmp_len = MultiByteToWideChar(vcp->vc_cpfrom, 0,
+ ptr, len, 0, 0);
+--- 6101,6107 ----
+
+ /* 1. codepage/UTF-8 -> ucs-2. */
+ if (vcp->vc_cpfrom == 0)
+! tmp_len = utf8_to_utf16(ptr, len, NULL, NULL);
+ else
+ tmp_len = MultiByteToWideChar(vcp->vc_cpfrom, 0,
+ ptr, len, 0, 0);
+***************
+*** 6109,6121 ****
+ if (tmp == NULL)
+ break;
+ if (vcp->vc_cpfrom == 0)
+! utf8_to_ucs2(ptr, len, tmp, unconvlenp);
+ else
+ MultiByteToWideChar(vcp->vc_cpfrom, 0, ptr, len, tmp, tmp_len);
+
+ /* 2. ucs-2 -> codepage/UTF-8. */
+ if (vcp->vc_cpto == 0)
+! retlen = ucs2_to_utf8(tmp, tmp_len, NULL);
+ else
+ retlen = WideCharToMultiByte(vcp->vc_cpto, 0,
+ tmp, tmp_len, 0, 0, 0, 0);
+--- 6109,6121 ----
+ if (tmp == NULL)
+ break;
+ if (vcp->vc_cpfrom == 0)
+! utf8_to_utf16(ptr, len, tmp, unconvlenp);
+ else
+ MultiByteToWideChar(vcp->vc_cpfrom, 0, ptr, len, tmp, tmp_len);
+
+ /* 2. ucs-2 -> codepage/UTF-8. */
+ if (vcp->vc_cpto == 0)
+! retlen = utf16_to_utf8(tmp, tmp_len, NULL);
+ else
+ retlen = WideCharToMultiByte(vcp->vc_cpto, 0,
+ tmp, tmp_len, 0, 0, 0, 0);
+***************
+*** 6123,6129 ****
+ if (retval != NULL)
+ {
+ if (vcp->vc_cpto == 0)
+! ucs2_to_utf8(tmp, tmp_len, retval);
+ else
+ WideCharToMultiByte(vcp->vc_cpto, 0,
+ tmp, tmp_len, retval, retlen, 0, 0);
+--- 6123,6129 ----
+ if (retval != NULL)
+ {
+ if (vcp->vc_cpto == 0)
+! utf16_to_utf8(tmp, tmp_len, retval);
+ else
+ WideCharToMultiByte(vcp->vc_cpto, 0,
+ tmp, tmp_len, retval, retlen, 0, 0);
+*** ../vim-7.2.048/src/misc1.c Sun Nov 9 13:43:25 2008
+--- src/misc1.c Thu Nov 20 16:42:59 2008
+***************
+*** 8728,8734 ****
+ /* The active codepage differs from 'encoding'. Attempt using the
+ * wide function. If it fails because it is not implemented fall back
+ * to the non-wide version (for Windows 98) */
+! wn = enc_to_ucs2(buf, NULL);
+ if (wn != NULL)
+ {
+ hFind = FindFirstFileW(wn, &wfb);
+--- 8728,8734 ----
+ /* The active codepage differs from 'encoding'. Attempt using the
+ * wide function. If it fails because it is not implemented fall back
+ * to the non-wide version (for Windows 98) */
+! wn = enc_to_utf16(buf, NULL);
+ if (wn != NULL)
+ {
+ hFind = FindFirstFileW(wn, &wfb);
+***************
+*** 8756,8762 ****
+ #ifdef WIN3264
+ # ifdef FEAT_MBYTE
+ if (wn != NULL)
+! p = ucs2_to_enc(wfb.cFileName, NULL); /* p is allocated here */
+ else
+ # endif
+ p = (char_u *)fb.cFileName;
+--- 8756,8762 ----
+ #ifdef WIN3264
+ # ifdef FEAT_MBYTE
+ if (wn != NULL)
+! p = utf16_to_enc(wfb.cFileName, NULL); /* p is allocated here */
+ else
+ # endif
+ p = (char_u *)fb.cFileName;
+***************
+*** 8830,8836 ****
+ if (wn != NULL)
+ {
+ vim_free(wn);
+! wn = enc_to_ucs2(buf, NULL);
+ if (wn != NULL)
+ hFind = FindFirstFileW(wn, &wfb);
+ }
+--- 8830,8836 ----
+ if (wn != NULL)
+ {
+ vim_free(wn);
+! wn = enc_to_utf16(buf, NULL);
+ if (wn != NULL)
+ hFind = FindFirstFileW(wn, &wfb);
+ }
+*** ../vim-7.2.048/src/os_mswin.c Sat Aug 9 19:37:30 2008
+--- src/os_mswin.c Thu Nov 20 17:05:10 2008
+***************
+*** 309,315 ****
+ if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+ {
+ /* Convert the title from 'encoding' to the active codepage. */
+! WCHAR *wp = enc_to_ucs2(title, NULL);
+ int n;
+
+ if (wp != NULL)
+--- 309,315 ----
+ if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+ {
+ /* Convert the title from 'encoding' to the active codepage. */
+! WCHAR *wp = enc_to_utf16(title, NULL);
+ int n;
+
+ if (wp != NULL)
+***************
+*** 406,415 ****
+ * - invoke _wfullpath()
+ * - convert the result from UCS2 to 'encoding'.
+ */
+! wname = enc_to_ucs2(fname, NULL);
+ if (wname != NULL && _wfullpath(wbuf, wname, MAX_PATH - 1) != NULL)
+ {
+! cname = ucs2_to_enc((short_u *)wbuf, NULL);
+ if (cname != NULL)
+ {
+ vim_strncpy(buf, cname, len - 1);
+--- 406,415 ----
+ * - invoke _wfullpath()
+ * - convert the result from UCS2 to 'encoding'.
+ */
+! wname = enc_to_utf16(fname, NULL);
+ if (wname != NULL && _wfullpath(wbuf, wname, MAX_PATH - 1) != NULL)
+ {
+! cname = utf16_to_enc((short_u *)wbuf, NULL);
+ if (cname != NULL)
+ {
+ vim_strncpy(buf, cname, len - 1);
+***************
+*** 507,513 ****
+ # endif
+ )
+ {
+! WCHAR *wp = enc_to_ucs2(buf, NULL);
+ int n;
+
+ if (wp != NULL)
+--- 507,513 ----
+ # endif
+ )
+ {
+! WCHAR *wp = enc_to_utf16(buf, NULL);
+ int n;
+
+ if (wp != NULL)
+***************
+*** 668,674 ****
+ #ifdef FEAT_MBYTE
+ if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+ {
+! WCHAR *p = enc_to_ucs2(path, NULL);
+ int n;
+
+ if (p != NULL)
+--- 668,674 ----
+ #ifdef FEAT_MBYTE
+ if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+ {
+! WCHAR *p = enc_to_utf16(path, NULL);
+ int n;
+
+ if (p != NULL)
+***************
+*** 891,909 ****
+
+ #if defined(FEAT_MBYTE) || defined(PROTO)
+ /*
+! * Convert an UTF-8 string to UCS-2.
+ * "instr[inlen]" is the input. "inlen" is in bytes.
+! * When "outstr" is NULL only return the number of UCS-2 words produced.
+ * Otherwise "outstr" must be a buffer of sufficient size.
+! * Returns the number of UCS-2 words produced.
+ */
+ int
+! utf8_to_ucs2(char_u *instr, int inlen, short_u *outstr, int *unconvlenp)
+ {
+ int outlen = 0;
+ char_u *p = instr;
+ int todo = inlen;
+ int l;
+
+ while (todo > 0)
+ {
+--- 891,910 ----
+
+ #if defined(FEAT_MBYTE) || defined(PROTO)
+ /*
+! * Convert an UTF-8 string to UTF-16.
+ * "instr[inlen]" is the input. "inlen" is in bytes.
+! * When "outstr" is NULL only return the number of UTF-16 words produced.
+ * Otherwise "outstr" must be a buffer of sufficient size.
+! * Returns the number of UTF-16 words produced.
+ */
+ int
+! utf8_to_utf16(char_u *instr, int inlen, short_u *outstr, int *unconvlenp)
+ {
+ int outlen = 0;
+ char_u *p = instr;
+ int todo = inlen;
+ int l;
++ int ch;
+
+ while (todo > 0)
+ {
+***************
+*** 917,924 ****
+ break;
+ }
+
+! if (outstr != NULL)
+! *outstr++ = utf_ptr2char(p);
+ ++outlen;
+ p += l;
+ todo -= l;
+--- 918,936 ----
+ break;
+ }
+
+! ch = utf_ptr2char(p);
+! if (ch >= 0x10000)
+! {
+! /* non-BMP character, encoding with surrogate pairs */
+! ++outlen;
+! if (outstr != NULL)
+! {
+! *outstr++ = (0xD800 - (0x10000 >> 10)) + (ch >> 10);
+! *outstr++ = 0xDC00 | (ch & 0x3FF);
+! }
+! }
+! else if (outstr != NULL)
+! *outstr++ = ch;
+ ++outlen;
+ p += l;
+ todo -= l;
+***************
+*** 928,956 ****
+ }
+
+ /*
+! * Convert an UCS-2 string to UTF-8.
+! * The input is "instr[inlen]" with "inlen" in number of ucs-2 words.
+ * When "outstr" is NULL only return the required number of bytes.
+ * Otherwise "outstr" must be a buffer of sufficient size.
+ * Return the number of bytes produced.
+ */
+ int
+! ucs2_to_utf8(short_u *instr, int inlen, char_u *outstr)
+ {
+ int outlen = 0;
+ int todo = inlen;
+ short_u *p = instr;
+ int l;
+
+ while (todo > 0)
+ {
+ if (outstr != NULL)
+ {
+! l = utf_char2bytes(*p, outstr);
+ outstr += l;
+ }
+ else
+! l = utf_char2len(*p);
+ ++p;
+ outlen += l;
+ --todo;
+--- 940,981 ----
+ }
+
+ /*
+! * Convert an UTF-16 string to UTF-8.
+! * The input is "instr[inlen]" with "inlen" in number of UTF-16 words.
+ * When "outstr" is NULL only return the required number of bytes.
+ * Otherwise "outstr" must be a buffer of sufficient size.
+ * Return the number of bytes produced.
+ */
+ int
+! utf16_to_utf8(short_u *instr, int inlen, char_u *outstr)
+ {
+ int outlen = 0;
+ int todo = inlen;
+ short_u *p = instr;
+ int l;
++ int ch, ch2;
+
+ while (todo > 0)
+ {
++ ch = *p;
++ if (ch >= 0xD800 && ch <= 0xDBFF && todo > 1)
++ {
++ /* surrogate pairs handling */
++ ch2 = p[1];
++ if (ch2 >= 0xDC00 && ch2 <= 0xDFFF)
++ {
++ ch = ((ch - 0xD800) << 10) + (ch2 & 0x3FF) + 0x10000;
++ ++p;
++ --todo;
++ }
++ }
+ if (outstr != NULL)
+ {
+! l = utf_char2bytes(ch, outstr);
+ outstr += l;
+ }
+ else
+! l = utf_char2len(ch);
+ ++p;
+ outlen += l;
+ --todo;
+***************
+*** 1079,1092 ****
+ */
+
+ /*
+! * Convert "str" from 'encoding' to UCS-2.
+ * Input in "str" with length "*lenp". When "lenp" is NULL, use strlen().
+ * Output is returned as an allocated string. "*lenp" is set to the length of
+ * the result. A trailing NUL is always added.
+ * Returns NULL when out of memory.
+ */
+ short_u *
+! enc_to_ucs2(char_u *str, int *lenp)
+ {
+ vimconv_T conv;
+ WCHAR *ret;
+--- 1104,1117 ----
+ */
+
+ /*
+! * Convert "str" from 'encoding' to UTF-16.
+ * Input in "str" with length "*lenp". When "lenp" is NULL, use strlen().
+ * Output is returned as an allocated string. "*lenp" is set to the length of
+ * the result. A trailing NUL is always added.
+ * Returns NULL when out of memory.
+ */
+ short_u *
+! enc_to_utf16(char_u *str, int *lenp)
+ {
+ vimconv_T conv;
+ WCHAR *ret;
+***************
+*** 1102,1108 ****
+
+ if (enc_codepage > 0)
+ {
+! /* We can do any CP### -> UCS-2 in one pass, and we can do it
+ * without iconv() (convert_* may need iconv). */
+ MultiByteToWideChar_alloc(enc_codepage, 0, str, *lenp, &ret, &length);
+ }
+--- 1127,1133 ----
+
+ if (enc_codepage > 0)
+ {
+! /* We can do any CP### -> UTF-16 in one pass, and we can do it
+ * without iconv() (convert_* may need iconv). */
+ MultiByteToWideChar_alloc(enc_codepage, 0, str, *lenp, &ret, &length);
+ }
+***************
+*** 1123,1133 ****
+ }
+ convert_setup(&conv, NULL, NULL);
+
+! length = utf8_to_ucs2(str, *lenp, NULL, NULL);
+ ret = (WCHAR *)alloc((unsigned)((length + 1) * sizeof(WCHAR)));
+ if (ret != NULL)
+ {
+! utf8_to_ucs2(str, *lenp, (short_u *)ret, NULL);
+ ret[length] = 0;
+ }
+
+--- 1148,1158 ----
+ }
+ convert_setup(&conv, NULL, NULL);
+
+! length = utf8_to_utf16(str, *lenp, NULL, NULL);
+ ret = (WCHAR *)alloc((unsigned)((length + 1) * sizeof(WCHAR)));
+ if (ret != NULL)
+ {
+! utf8_to_utf16(str, *lenp, (short_u *)ret, NULL);
+ ret[length] = 0;
+ }
+
+***************
+*** 1139,1145 ****
+ }
+
+ /*
+! * Convert an UCS-2 string to 'encoding'.
+ * Input in "str" with length (counted in wide characters) "*lenp". When
+ * "lenp" is NULL, use wcslen().
+ * Output is returned as an allocated string. If "*lenp" is not NULL it is
+--- 1164,1170 ----
+ }
+
+ /*
+! * Convert an UTF-16 string to 'encoding'.
+ * Input in "str" with length (counted in wide characters) "*lenp". When
+ * "lenp" is NULL, use wcslen().
+ * Output is returned as an allocated string. If "*lenp" is not NULL it is
+***************
+*** 1147,1153 ****
+ * Returns NULL when out of memory.
+ */
+ char_u *
+! ucs2_to_enc(short_u *str, int *lenp)
+ {
+ vimconv_T conv;
+ char_u *utf8_str = NULL, *enc_str = NULL;
+--- 1172,1178 ----
+ * Returns NULL when out of memory.
+ */
+ char_u *
+! utf16_to_enc(short_u *str, int *lenp)
+ {
+ vimconv_T conv;
+ char_u *utf8_str = NULL, *enc_str = NULL;
+***************
+*** 1161,1167 ****
+
+ if (enc_codepage > 0)
+ {
+! /* We can do any UCS-2 -> CP### in one pass. */
+ int length;
+
+ WideCharToMultiByte_alloc(enc_codepage, 0, str, *lenp,
+--- 1186,1192 ----
+
+ if (enc_codepage > 0)
+ {
+! /* We can do any UTF-16 -> CP### in one pass. */
+ int length;
+
+ WideCharToMultiByte_alloc(enc_codepage, 0, str, *lenp,
+***************
+*** 1171,1180 ****
+ }
+
+ /* Avoid allocating zero bytes, it generates an error message. */
+! utf8_str = alloc(ucs2_to_utf8(str, *lenp == 0 ? 1 : *lenp, NULL));
+ if (utf8_str != NULL)
+ {
+! *lenp = ucs2_to_utf8(str, *lenp, utf8_str);
+
+ /* We might be called before we have p_enc set up. */
+ conv.vc_type = CONV_NONE;
+--- 1196,1205 ----
+ }
+
+ /* Avoid allocating zero bytes, it generates an error message. */
+! utf8_str = alloc(utf16_to_utf8(str, *lenp == 0 ? 1 : *lenp, NULL));
+ if (utf8_str != NULL)
+ {
+! *lenp = utf16_to_utf8(str, *lenp, utf8_str);
+
+ /* We might be called before we have p_enc set up. */
+ conv.vc_type = CONV_NONE;
+***************
+*** 1308,1314 ****
+ if (hMemWstr[str_size] == NUL)
+ break;
+ }
+! to_free = str = ucs2_to_enc((short_u *)hMemWstr, &str_size);
+ GlobalUnlock(hMemW);
+ }
+ }
+--- 1333,1339 ----
+ if (hMemWstr[str_size] == NUL)
+ break;
+ }
+! to_free = str = utf16_to_enc((short_u *)hMemWstr, &str_size);
+ GlobalUnlock(hMemW);
+ }
+ }
+***************
+*** 1340,1346 ****
+
+ # if defined(FEAT_MBYTE) && defined(WIN3264)
+ /* The text is in the active codepage. Convert to 'encoding',
+! * going through UCS-2. */
+ acp_to_enc(str, str_size, &to_free, &maxlen);
+ if (to_free != NULL)
+ {
+--- 1365,1371 ----
+
+ # if defined(FEAT_MBYTE) && defined(WIN3264)
+ /* The text is in the active codepage. Convert to 'encoding',
+! * going through UTF-16. */
+ acp_to_enc(str, str_size, &to_free, &maxlen);
+ if (to_free != NULL)
+ {
+***************
+*** 1404,1410 ****
+ if (widestr != NULL)
+ {
+ ++*outlen; /* Include the 0 after the string */
+! *out = ucs2_to_enc((short_u *)widestr, outlen);
+ vim_free(widestr);
+ }
+ }
+--- 1429,1435 ----
+ if (widestr != NULL)
+ {
+ ++*outlen; /* Include the 0 after the string */
+! *out = utf16_to_enc((short_u *)widestr, outlen);
+ vim_free(widestr);
+ }
+ }
+***************
+*** 1466,1474 ****
+ WCHAR *out;
+ int len = metadata.txtlen;
+
+! /* Convert the text to UCS-2. This is put on the clipboard as
+ * CF_UNICODETEXT. */
+! out = (WCHAR *)enc_to_ucs2(str, &len);
+ if (out != NULL)
+ {
+ WCHAR *lpszMemW;
+--- 1491,1499 ----
+ WCHAR *out;
+ int len = metadata.txtlen;
+
+! /* Convert the text to UTF-16. This is put on the clipboard as
+ * CF_UNICODETEXT. */
+! out = (WCHAR *)enc_to_utf16(str, &len);
+ if (out != NULL)
+ {
+ WCHAR *lpszMemW;
+***************
+*** 1488,1494 ****
+ WideCharToMultiByte(GetACP(), 0, out, len,
+ str, metadata.txtlen, 0, 0);
+
+! /* Allocate memory for the UCS-2 text, add one NUL word to
+ * terminate the string. */
+ hMemW = (LPSTR)GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE,
+ (len + 1) * sizeof(WCHAR));
+--- 1513,1519 ----
+ WideCharToMultiByte(GetACP(), 0, out, len,
+ str, metadata.txtlen, 0, 0);
+
+! /* Allocate memory for the UTF-16 text, add one NUL word to
+ * terminate the string. */
+ hMemW = (LPSTR)GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE,
+ (len + 1) * sizeof(WCHAR));
+*** ../vim-7.2.048/src/os_win32.c Thu Jul 24 20:50:30 2008
+--- src/os_win32.c Thu Nov 20 16:44:33 2008
+***************
+*** 1587,1593 ****
+ #ifdef FEAT_MBYTE
+ if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+ {
+! WCHAR *p = enc_to_ucs2(name, NULL);
+ WCHAR fnamew[_MAX_PATH];
+ WCHAR *dumw;
+ long n;
+--- 1587,1593 ----
+ #ifdef FEAT_MBYTE
+ if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+ {
+! WCHAR *p = enc_to_utf16(name, NULL);
+ WCHAR fnamew[_MAX_PATH];
+ WCHAR *dumw;
+ long n;
+***************
+*** 2440,2446 ****
+
+ if (GetCurrentDirectoryW(_MAX_PATH, wbuf) != 0)
+ {
+! char_u *p = ucs2_to_enc(wbuf, NULL);
+
+ if (p != NULL)
+ {
+--- 2440,2446 ----
+
+ if (GetCurrentDirectoryW(_MAX_PATH, wbuf) != 0)
+ {
+! char_u *p = utf16_to_enc(wbuf, NULL);
+
+ if (p != NULL)
+ {
+***************
+*** 2466,2472 ****
+ #ifdef FEAT_MBYTE
+ if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+ {
+! WCHAR *p = enc_to_ucs2(name, NULL);
+ long n;
+
+ if (p != NULL)
+--- 2466,2472 ----
+ #ifdef FEAT_MBYTE
+ if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+ {
+! WCHAR *p = enc_to_utf16(name, NULL);
+ long n;
+
+ if (p != NULL)
+***************
+*** 2495,2501 ****
+ #ifdef FEAT_MBYTE
+ if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+ {
+! WCHAR *p = enc_to_ucs2(name, NULL);
+ long n;
+
+ if (p != NULL)
+--- 2495,2501 ----
+ #ifdef FEAT_MBYTE
+ if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+ {
+! WCHAR *p = enc_to_utf16(name, NULL);
+ long n;
+
+ if (p != NULL)
+***************
+*** 2522,2528 ****
+ WCHAR *p = NULL;
+
+ if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+! p = enc_to_ucs2(name, NULL);
+ #endif
+
+ #ifdef FEAT_MBYTE
+--- 2522,2528 ----
+ WCHAR *p = NULL;
+
+ if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+! p = enc_to_utf16(name, NULL);
+ #endif
+
+ #ifdef FEAT_MBYTE
+***************
+*** 2590,2596 ****
+ WCHAR *wn = NULL;
+
+ if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+! wn = enc_to_ucs2(fname, NULL);
+ if (wn != NULL)
+ {
+ hFile = CreateFileW(wn, /* file name */
+--- 2590,2596 ----
+ WCHAR *wn = NULL;
+
+ if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+! wn = enc_to_utf16(fname, NULL);
+ if (wn != NULL)
+ {
+ hFile = CreateFileW(wn, /* file name */
+***************
+*** 4239,4245 ****
+
+ if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+ {
+! wn = enc_to_ucs2(name, NULL);
+ if (wn != NULL)
+ {
+ SetFileAttributesW(wn, FILE_ATTRIBUTE_NORMAL);
+--- 4239,4245 ----
+
+ if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+ {
+! wn = enc_to_utf16(name, NULL);
+ if (wn != NULL)
+ {
+ SetFileAttributesW(wn, FILE_ATTRIBUTE_NORMAL);
+***************
+*** 4382,4389 ****
+
+ if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+ {
+! wold = enc_to_ucs2((char_u *)pszOldFile, NULL);
+! wnew = enc_to_ucs2((char_u *)pszNewFile, NULL);
+ if (wold != NULL && wnew != NULL)
+ retval = mch_wrename(wold, wnew);
+ vim_free(wold);
+--- 4382,4389 ----
+
+ if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+ {
+! wold = enc_to_utf16((char_u *)pszOldFile, NULL);
+! wnew = enc_to_utf16((char_u *)pszNewFile, NULL);
+ if (wold != NULL && wnew != NULL)
+ retval = mch_wrename(wold, wnew);
+ vim_free(wold);
+***************
+*** 4492,4498 ****
+ WCHAR *wn = NULL;
+
+ if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+! wn = enc_to_ucs2(n, NULL);
+ #endif
+
+ if (mch_isdir(n))
+--- 4492,4498 ----
+ WCHAR *wn = NULL;
+
+ if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+! wn = enc_to_utf16(n, NULL);
+ #endif
+
+ if (mch_isdir(n))
+***************
+*** 4618,4624 ****
+
+ #if defined(FEAT_MBYTE) || defined(PROTO)
+ /*
+! * Version of open() that may use ucs2 file name.
+ */
+ int
+ mch_open(char *name, int flags, int mode)
+--- 4618,4624 ----
+
+ #if defined(FEAT_MBYTE) || defined(PROTO)
+ /*
+! * Version of open() that may use UTF-16 file name.
+ */
+ int
+ mch_open(char *name, int flags, int mode)
+***************
+*** 4630,4636 ****
+
+ if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+ {
+! wn = enc_to_ucs2(name, NULL);
+ if (wn != NULL)
+ {
+ f = _wopen(wn, flags, mode);
+--- 4630,4636 ----
+
+ if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+ {
+! wn = enc_to_utf16(name, NULL);
+ if (wn != NULL)
+ {
+ f = _wopen(wn, flags, mode);
+***************
+*** 4648,4654 ****
+ }
+
+ /*
+! * Version of fopen() that may use ucs2 file name.
+ */
+ FILE *
+ mch_fopen(char *name, char *mode)
+--- 4648,4654 ----
+ }
+
+ /*
+! * Version of fopen() that may use UTF-16 file name.
+ */
+ FILE *
+ mch_fopen(char *name, char *mode)
+***************
+*** 4675,4682 ****
+ else if (newMode == 'b')
+ _set_fmode(_O_BINARY);
+ # endif
+! wn = enc_to_ucs2(name, NULL);
+! wm = enc_to_ucs2(mode, NULL);
+ if (wn != NULL && wm != NULL)
+ f = _wfopen(wn, wm);
+ vim_free(wn);
+--- 4675,4682 ----
+ else if (newMode == 'b')
+ _set_fmode(_O_BINARY);
+ # endif
+! wn = enc_to_utf16(name, NULL);
+! wm = enc_to_utf16(mode, NULL);
+ if (wn != NULL && wm != NULL)
+ f = _wfopen(wn, wm);
+ vim_free(wn);
+***************
+*** 4776,4783 ****
+ int len;
+
+ /* Convert the file names to wide characters. */
+! fromw = enc_to_ucs2(from, NULL);
+! tow = enc_to_ucs2(to, NULL);
+ if (fromw != NULL && tow != NULL)
+ {
+ /* Open the file for reading. */
+--- 4776,4783 ----
+ int len;
+
+ /* Convert the file names to wide characters. */
+! fromw = enc_to_utf16(from, NULL);
+! tow = enc_to_utf16(to, NULL);
+ if (fromw != NULL && tow != NULL)
+ {
+ /* Open the file for reading. */
+***************
+*** 5122,5128 ****
+ for (i = 0; i < used_file_count; ++i)
+ {
+ idx = used_file_indexes[i];
+! str = ucs2_to_enc(ArglistW[idx], NULL);
+ if (str != NULL)
+ {
+ #ifdef FEAT_DIFF
+--- 5122,5128 ----
+ for (i = 0; i < used_file_count; ++i)
+ {
+ idx = used_file_indexes[i];
+! str = utf16_to_enc(ArglistW[idx], NULL);
+ if (str != NULL)
+ {
+ #ifdef FEAT_DIFF
+*** ../vim-7.2.048/src/proto/os_mswin.pro Sat May 5 19:07:50 2007
+--- src/proto/os_mswin.pro Thu Nov 20 16:41:00 2008
+***************
+*** 22,35 ****
+ int can_end_termcap_mode __ARGS((int give_msg));
+ int mch_screenmode __ARGS((char_u *arg));
+ int mch_libcall __ARGS((char_u *libname, char_u *funcname, char_u *argstring, int argint, char_u **string_result, int *number_result));
+! int utf8_to_ucs2 __ARGS((char_u *instr, int inlen, short_u *outstr, int *unconvlenp));
+! int ucs2_to_utf8 __ARGS((short_u *instr, int inlen, char_u *outstr));
+ void MultiByteToWideChar_alloc __ARGS((UINT cp, DWORD flags, LPCSTR in, int inlen, LPWSTR *out, int *outlen));
+ void WideCharToMultiByte_alloc __ARGS((UINT cp, DWORD flags, LPCWSTR in, int inlen, LPSTR *out, int *outlen, LPCSTR def, LPBOOL useddef));
+ int clip_mch_own_selection __ARGS((VimClipboard *cbd));
+ void clip_mch_lose_selection __ARGS((VimClipboard *cbd));
+! short_u *enc_to_ucs2 __ARGS((char_u *str, int *lenp));
+! char_u *ucs2_to_enc __ARGS((short_u *str, int *lenp));
+ void clip_mch_request_selection __ARGS((VimClipboard *cbd));
+ void acp_to_enc __ARGS((char_u *str, int str_size, char_u **out, int *outlen));
+ void clip_mch_set_selection __ARGS((VimClipboard *cbd));
+--- 22,35 ----
+ int can_end_termcap_mode __ARGS((int give_msg));
+ int mch_screenmode __ARGS((char_u *arg));
+ int mch_libcall __ARGS((char_u *libname, char_u *funcname, char_u *argstring, int argint, char_u **string_result, int *number_result));
+! int utf8_to_utf16 __ARGS((char_u *instr, int inlen, short_u *outstr, int *unconvlenp));
+! int utf16_to_utf8 __ARGS((short_u *instr, int inlen, char_u *outstr));
+ void MultiByteToWideChar_alloc __ARGS((UINT cp, DWORD flags, LPCSTR in, int inlen, LPWSTR *out, int *outlen));
+ void WideCharToMultiByte_alloc __ARGS((UINT cp, DWORD flags, LPCWSTR in, int inlen, LPSTR *out, int *outlen, LPCSTR def, LPBOOL useddef));
+ int clip_mch_own_selection __ARGS((VimClipboard *cbd));
+ void clip_mch_lose_selection __ARGS((VimClipboard *cbd));
+! short_u *enc_to_utf16 __ARGS((char_u *str, int *lenp));
+! char_u *utf16_to_enc __ARGS((short_u *str, int *lenp));
+ void clip_mch_request_selection __ARGS((VimClipboard *cbd));
+ void acp_to_enc __ARGS((char_u *str, int str_size, char_u **out, int *outlen));
+ void clip_mch_set_selection __ARGS((VimClipboard *cbd));
+*** ../vim-7.2.048/src/version.c Thu Nov 20 16:11:03 2008
+--- src/version.c Thu Nov 20 17:08:07 2008
+***************
+*** 678,679 ****
+--- 678,681 ----
+ { /* Add new patch number below this line */
++ /**/
++ 49,
+ /**/
+
+--
+FIRST HEAD: All right! All right! We'll kill him first and then have tea and
+ biscuits.
+ "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
+
+ /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
+/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
+\\\ download, build and distribute -- http://www.A-A-P.org ///
+ \\\ help me help AIDS victims -- http://ICCF-Holland.org ///