summaryrefslogtreecommitdiff
path: root/src/os_mswin.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2005-02-26 23:04:13 +0000
committerBram Moolenaar <Bram@vim.org>2005-02-26 23:04:13 +0000
commit05159a0c6a27a030c8497c5cf836977090f9e75d (patch)
tree9ccc167cf3e830e5d01aff4555f99d854cbb623b /src/os_mswin.c
parent5313dcb75ac76501f23d21ac94efdbeeabc860bc (diff)
downloadvim-git-05159a0c6a27a030c8497c5cf836977090f9e75d.tar.gz
updated for version 7.0052v7.0052
Diffstat (limited to 'src/os_mswin.c')
-rw-r--r--src/os_mswin.c39
1 files changed, 29 insertions, 10 deletions
diff --git a/src/os_mswin.c b/src/os_mswin.c
index 5d45d7bfb..4f3a49bef 100644
--- a/src/os_mswin.c
+++ b/src/os_mswin.c
@@ -1346,22 +1346,16 @@ clip_mch_request_selection(VimClipboard *cbd)
break;
}
-#if defined(FEAT_MBYTE) && defined(WIN3264)
+# if defined(FEAT_MBYTE) && defined(WIN3264)
/* The text is in the active codepage. Convert to 'encoding',
* going through UCS-2. */
- MultiByteToWideChar_alloc(GetACP(), 0, str, str_size,
- (LPWSTR *)&to_free, &maxlen);
+ acp_to_enc(str, str_size, &to_free, &maxlen);
if (to_free != NULL)
{
str_size = maxlen;
- str = ucs2_to_enc((short_u *)to_free, &str_size);
- if (str != NULL)
- {
- vim_free(to_free);
- to_free = str;
- }
+ str = to_free;
}
-#endif
+# endif
}
}
#ifdef FEAT_MBYTE
@@ -1398,6 +1392,31 @@ clip_mch_request_selection(VimClipboard *cbd)
#endif
}
+#if (defined(FEAT_MBYTE) && defined(WIN3264)) || defined(PROTO)
+/*
+ * Convert from the active codepage to 'encoding'.
+ * Input is "str[str_size]".
+ * The result is in allocated memory: "out[outlen]". With terminating NUL.
+ */
+ void
+acp_to_enc(str, str_size, out, outlen)
+ char_u *str;
+ int str_size;
+ char_u **out;
+ int *outlen;
+
+{
+ LPWSTR widestr;
+
+ MultiByteToWideChar_alloc(GetACP(), 0, str, str_size, &widestr, outlen);
+ if (widestr != NULL)
+ {
+ *out = ucs2_to_enc((short_u *)widestr, outlen);
+ vim_free(widestr);
+ }
+}
+#endif
+
/*
* Send the current selection to the clipboard.
*/