Mercurial > vim
diff src/os_mswin.c @ 170:8c60f65311fa v7.0052
updated for version 7.0052
author | vimboss |
---|---|
date | Sat, 26 Feb 2005 23:04:13 +0000 |
parents | 5242c44962c2 |
children | 7fd70926e2e1 |
line wrap: on
line diff
--- a/src/os_mswin.c +++ b/src/os_mswin.c @@ -1346,22 +1346,16 @@ clip_mch_request_selection(VimClipboard 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 #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. */