|
Karsten Hopp |
26431a |
To: vim_dev@googlegroups.com
|
|
Karsten Hopp |
26431a |
Subject: Patch 7.3.223
|
|
Karsten Hopp |
26431a |
Fcc: outbox
|
|
Karsten Hopp |
26431a |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
26431a |
Mime-Version: 1.0
|
|
Karsten Hopp |
26431a |
Content-Type: text/plain; charset=UTF-8
|
|
Karsten Hopp |
26431a |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
26431a |
------------
|
|
Karsten Hopp |
26431a |
|
|
Karsten Hopp |
26431a |
Patch 7.3.223
|
|
Karsten Hopp |
26431a |
Problem: MingW cross compilation doesn't work with tiny features.
|
|
Karsten Hopp |
26431a |
Solution: Move acp_to_enc(), enc_to_utf16() and utf16_to_enc() outside of
|
|
Karsten Hopp |
26431a |
"#ifdef CLIPBOARD". Fix typo in makefile.
|
|
Karsten Hopp |
26431a |
Files: src/Make_ming.mak, src/os_mswin.c
|
|
Karsten Hopp |
26431a |
|
|
Karsten Hopp |
26431a |
|
|
Karsten Hopp |
26431a |
*** ../mercurial/vim73/src/Make_ming.mak 2010-12-30 14:50:46.000000000 +0100
|
|
Karsten Hopp |
26431a |
--- src/Make_ming.mak 2011-06-19 01:20:16.000000000 +0200
|
|
Karsten Hopp |
26431a |
***************
|
|
Karsten Hopp |
26431a |
*** 87,93 ****
|
|
Karsten Hopp |
26431a |
|
|
Karsten Hopp |
26431a |
# If you are using gettext-0.10.35 from http://sourceforge.net/projects/gettext
|
|
Karsten Hopp |
26431a |
# or gettext-0.10.37 from http://sourceforge.net/projects/mingwrep/
|
|
Karsten Hopp |
26431a |
! # uncomment the following, but I can't build a static versiĆ³n with them, ?-(|
|
|
Karsten Hopp |
26431a |
#GETTEXT=c:/gettext-0.10.37-20010430
|
|
Karsten Hopp |
26431a |
#STATIC_GETTEXT=USE_STATIC_GETTEXT
|
|
Karsten Hopp |
26431a |
#DYNAMIC_GETTEXT=DYNAMIC_GETTEXT
|
|
Karsten Hopp |
26431a |
--- 87,93 ----
|
|
Karsten Hopp |
26431a |
|
|
Karsten Hopp |
26431a |
# If you are using gettext-0.10.35 from http://sourceforge.net/projects/gettext
|
|
Karsten Hopp |
26431a |
# or gettext-0.10.37 from http://sourceforge.net/projects/mingwrep/
|
|
Karsten Hopp |
26431a |
! # uncomment the following, but I can't build a static version with them, ?-(|
|
|
Karsten Hopp |
26431a |
#GETTEXT=c:/gettext-0.10.37-20010430
|
|
Karsten Hopp |
26431a |
#STATIC_GETTEXT=USE_STATIC_GETTEXT
|
|
Karsten Hopp |
26431a |
#DYNAMIC_GETTEXT=DYNAMIC_GETTEXT
|
|
Karsten Hopp |
26431a |
*** ../mercurial/vim73/src/os_mswin.c 2011-06-19 01:14:23.000000000 +0200
|
|
Karsten Hopp |
26431a |
--- src/os_mswin.c 2011-06-19 01:25:23.000000000 +0200
|
|
Karsten Hopp |
26431a |
***************
|
|
Karsten Hopp |
26431a |
*** 1105,1236 ****
|
|
Karsten Hopp |
26431a |
return ret;
|
|
Karsten Hopp |
26431a |
}
|
|
Karsten Hopp |
26431a |
|
|
Karsten Hopp |
26431a |
- #if defined(FEAT_MBYTE) || defined(PROTO)
|
|
Karsten Hopp |
26431a |
- /*
|
|
Karsten Hopp |
26431a |
- * Note: the following two functions are only guaranteed to work when using
|
|
Karsten Hopp |
26431a |
- * valid MS-Windows codepages or when iconv() is available.
|
|
Karsten Hopp |
26431a |
- */
|
|
Karsten Hopp |
26431a |
-
|
|
Karsten Hopp |
26431a |
- /*
|
|
Karsten Hopp |
26431a |
- * Convert "str" from 'encoding' to UTF-16.
|
|
Karsten Hopp |
26431a |
- * Input in "str" with length "*lenp". When "lenp" is NULL, use strlen().
|
|
Karsten Hopp |
26431a |
- * Output is returned as an allocated string. "*lenp" is set to the length of
|
|
Karsten Hopp |
26431a |
- * the result. A trailing NUL is always added.
|
|
Karsten Hopp |
26431a |
- * Returns NULL when out of memory.
|
|
Karsten Hopp |
26431a |
- */
|
|
Karsten Hopp |
26431a |
- short_u *
|
|
Karsten Hopp |
26431a |
- enc_to_utf16(char_u *str, int *lenp)
|
|
Karsten Hopp |
26431a |
- {
|
|
Karsten Hopp |
26431a |
- vimconv_T conv;
|
|
Karsten Hopp |
26431a |
- WCHAR *ret;
|
|
Karsten Hopp |
26431a |
- char_u *allocbuf = NULL;
|
|
Karsten Hopp |
26431a |
- int len_loc;
|
|
Karsten Hopp |
26431a |
- int length;
|
|
Karsten Hopp |
26431a |
-
|
|
Karsten Hopp |
26431a |
- if (lenp == NULL)
|
|
Karsten Hopp |
26431a |
- {
|
|
Karsten Hopp |
26431a |
- len_loc = (int)STRLEN(str) + 1;
|
|
Karsten Hopp |
26431a |
- lenp = &len_loc;
|
|
Karsten Hopp |
26431a |
- }
|
|
Karsten Hopp |
26431a |
-
|
|
Karsten Hopp |
26431a |
- if (enc_codepage > 0)
|
|
Karsten Hopp |
26431a |
- {
|
|
Karsten Hopp |
26431a |
- /* We can do any CP### -> UTF-16 in one pass, and we can do it
|
|
Karsten Hopp |
26431a |
- * without iconv() (convert_* may need iconv). */
|
|
Karsten Hopp |
26431a |
- MultiByteToWideChar_alloc(enc_codepage, 0, str, *lenp, &ret, &length);
|
|
Karsten Hopp |
26431a |
- }
|
|
Karsten Hopp |
26431a |
- else
|
|
Karsten Hopp |
26431a |
- {
|
|
Karsten Hopp |
26431a |
- /* Use "latin1" by default, we might be called before we have p_enc
|
|
Karsten Hopp |
26431a |
- * set up. Convert to utf-8 first, works better with iconv(). Does
|
|
Karsten Hopp |
26431a |
- * nothing if 'encoding' is "utf-8". */
|
|
Karsten Hopp |
26431a |
- conv.vc_type = CONV_NONE;
|
|
Karsten Hopp |
26431a |
- if (convert_setup(&conv, p_enc ? p_enc : (char_u *)"latin1",
|
|
Karsten Hopp |
26431a |
- (char_u *)"utf-8") == FAIL)
|
|
Karsten Hopp |
26431a |
- return NULL;
|
|
Karsten Hopp |
26431a |
- if (conv.vc_type != CONV_NONE)
|
|
Karsten Hopp |
26431a |
- {
|
|
Karsten Hopp |
26431a |
- str = allocbuf = string_convert(&conv, str, lenp);
|
|
Karsten Hopp |
26431a |
- if (str == NULL)
|
|
Karsten Hopp |
26431a |
- return NULL;
|
|
Karsten Hopp |
26431a |
- }
|
|
Karsten Hopp |
26431a |
- convert_setup(&conv, NULL, NULL);
|
|
Karsten Hopp |
26431a |
-
|
|
Karsten Hopp |
26431a |
- length = utf8_to_utf16(str, *lenp, NULL, NULL);
|
|
Karsten Hopp |
26431a |
- ret = (WCHAR *)alloc((unsigned)((length + 1) * sizeof(WCHAR)));
|
|
Karsten Hopp |
26431a |
- if (ret != NULL)
|
|
Karsten Hopp |
26431a |
- {
|
|
Karsten Hopp |
26431a |
- utf8_to_utf16(str, *lenp, (short_u *)ret, NULL);
|
|
Karsten Hopp |
26431a |
- ret[length] = 0;
|
|
Karsten Hopp |
26431a |
- }
|
|
Karsten Hopp |
26431a |
-
|
|
Karsten Hopp |
26431a |
- vim_free(allocbuf);
|
|
Karsten Hopp |
26431a |
- }
|
|
Karsten Hopp |
26431a |
-
|
|
Karsten Hopp |
26431a |
- *lenp = length;
|
|
Karsten Hopp |
26431a |
- return (short_u *)ret;
|
|
Karsten Hopp |
26431a |
- }
|
|
Karsten Hopp |
26431a |
-
|
|
Karsten Hopp |
26431a |
- /*
|
|
Karsten Hopp |
26431a |
- * Convert an UTF-16 string to 'encoding'.
|
|
Karsten Hopp |
26431a |
- * Input in "str" with length (counted in wide characters) "*lenp". When
|
|
Karsten Hopp |
26431a |
- * "lenp" is NULL, use wcslen().
|
|
Karsten Hopp |
26431a |
- * Output is returned as an allocated string. If "*lenp" is not NULL it is
|
|
Karsten Hopp |
26431a |
- * set to the length of the result.
|
|
Karsten Hopp |
26431a |
- * Returns NULL when out of memory.
|
|
Karsten Hopp |
26431a |
- */
|
|
Karsten Hopp |
26431a |
- char_u *
|
|
Karsten Hopp |
26431a |
- utf16_to_enc(short_u *str, int *lenp)
|
|
Karsten Hopp |
26431a |
- {
|
|
Karsten Hopp |
26431a |
- vimconv_T conv;
|
|
Karsten Hopp |
26431a |
- char_u *utf8_str = NULL, *enc_str = NULL;
|
|
Karsten Hopp |
26431a |
- int len_loc;
|
|
Karsten Hopp |
26431a |
-
|
|
Karsten Hopp |
26431a |
- if (lenp == NULL)
|
|
Karsten Hopp |
26431a |
- {
|
|
Karsten Hopp |
26431a |
- len_loc = (int)wcslen(str) + 1;
|
|
Karsten Hopp |
26431a |
- lenp = &len_loc;
|
|
Karsten Hopp |
26431a |
- }
|
|
Karsten Hopp |
26431a |
-
|
|
Karsten Hopp |
26431a |
- if (enc_codepage > 0)
|
|
Karsten Hopp |
26431a |
- {
|
|
Karsten Hopp |
26431a |
- /* We can do any UTF-16 -> CP### in one pass. */
|
|
Karsten Hopp |
26431a |
- int length;
|
|
Karsten Hopp |
26431a |
-
|
|
Karsten Hopp |
26431a |
- WideCharToMultiByte_alloc(enc_codepage, 0, str, *lenp,
|
|
Karsten Hopp |
26431a |
- (LPSTR *)&enc_str, &length, 0, 0);
|
|
Karsten Hopp |
26431a |
- *lenp = length;
|
|
Karsten Hopp |
26431a |
- return enc_str;
|
|
Karsten Hopp |
26431a |
- }
|
|
Karsten Hopp |
26431a |
-
|
|
Karsten Hopp |
26431a |
- /* Avoid allocating zero bytes, it generates an error message. */
|
|
Karsten Hopp |
26431a |
- utf8_str = alloc(utf16_to_utf8(str, *lenp == 0 ? 1 : *lenp, NULL));
|
|
Karsten Hopp |
26431a |
- if (utf8_str != NULL)
|
|
Karsten Hopp |
26431a |
- {
|
|
Karsten Hopp |
26431a |
- *lenp = utf16_to_utf8(str, *lenp, utf8_str);
|
|
Karsten Hopp |
26431a |
-
|
|
Karsten Hopp |
26431a |
- /* We might be called before we have p_enc set up. */
|
|
Karsten Hopp |
26431a |
- conv.vc_type = CONV_NONE;
|
|
Karsten Hopp |
26431a |
- convert_setup(&conv, (char_u *)"utf-8",
|
|
Karsten Hopp |
26431a |
- p_enc? p_enc: (char_u *)"latin1");
|
|
Karsten Hopp |
26431a |
- if (conv.vc_type == CONV_NONE)
|
|
Karsten Hopp |
26431a |
- {
|
|
Karsten Hopp |
26431a |
- /* p_enc is utf-8, so we're done. */
|
|
Karsten Hopp |
26431a |
- enc_str = utf8_str;
|
|
Karsten Hopp |
26431a |
- }
|
|
Karsten Hopp |
26431a |
- else
|
|
Karsten Hopp |
26431a |
- {
|
|
Karsten Hopp |
26431a |
- enc_str = string_convert(&conv, utf8_str, lenp);
|
|
Karsten Hopp |
26431a |
- vim_free(utf8_str);
|
|
Karsten Hopp |
26431a |
- }
|
|
Karsten Hopp |
26431a |
-
|
|
Karsten Hopp |
26431a |
- convert_setup(&conv, NULL, NULL);
|
|
Karsten Hopp |
26431a |
- }
|
|
Karsten Hopp |
26431a |
-
|
|
Karsten Hopp |
26431a |
- return enc_str;
|
|
Karsten Hopp |
26431a |
- }
|
|
Karsten Hopp |
26431a |
- #endif /* FEAT_MBYTE */
|
|
Karsten Hopp |
26431a |
-
|
|
Karsten Hopp |
26431a |
/*
|
|
Karsten Hopp |
26431a |
* Wait for another process to Close the Clipboard.
|
|
Karsten Hopp |
26431a |
* Returns TRUE for success.
|
|
Karsten Hopp |
26431a |
--- 1105,1110 ----
|
|
Karsten Hopp |
26431a |
***************
|
|
Karsten Hopp |
26431a |
*** 1436,1467 ****
|
|
Karsten Hopp |
26431a |
#endif
|
|
Karsten Hopp |
26431a |
}
|
|
Karsten Hopp |
26431a |
|
|
Karsten Hopp |
26431a |
- #if (defined(FEAT_MBYTE) && defined(WIN3264)) || defined(PROTO)
|
|
Karsten Hopp |
26431a |
- /*
|
|
Karsten Hopp |
26431a |
- * Convert from the active codepage to 'encoding'.
|
|
Karsten Hopp |
26431a |
- * Input is "str[str_size]".
|
|
Karsten Hopp |
26431a |
- * The result is in allocated memory: "out[outlen]". With terminating NUL.
|
|
Karsten Hopp |
26431a |
- */
|
|
Karsten Hopp |
26431a |
- void
|
|
Karsten Hopp |
26431a |
- acp_to_enc(str, str_size, out, outlen)
|
|
Karsten Hopp |
26431a |
- char_u *str;
|
|
Karsten Hopp |
26431a |
- int str_size;
|
|
Karsten Hopp |
26431a |
- char_u **out;
|
|
Karsten Hopp |
26431a |
- int *outlen;
|
|
Karsten Hopp |
26431a |
-
|
|
Karsten Hopp |
26431a |
- {
|
|
Karsten Hopp |
26431a |
- LPWSTR widestr;
|
|
Karsten Hopp |
26431a |
-
|
|
Karsten Hopp |
26431a |
- MultiByteToWideChar_alloc(GetACP(), 0, str, str_size, &widestr, outlen);
|
|
Karsten Hopp |
26431a |
- if (widestr != NULL)
|
|
Karsten Hopp |
26431a |
- {
|
|
Karsten Hopp |
26431a |
- ++*outlen; /* Include the 0 after the string */
|
|
Karsten Hopp |
26431a |
- *out = utf16_to_enc((short_u *)widestr, outlen);
|
|
Karsten Hopp |
26431a |
- vim_free(widestr);
|
|
Karsten Hopp |
26431a |
- }
|
|
Karsten Hopp |
26431a |
- }
|
|
Karsten Hopp |
26431a |
- #endif
|
|
Karsten Hopp |
26431a |
-
|
|
Karsten Hopp |
26431a |
/*
|
|
Karsten Hopp |
26431a |
* Send the current selection to the clipboard.
|
|
Karsten Hopp |
26431a |
*/
|
|
Karsten Hopp |
26431a |
--- 1310,1315 ----
|
|
Karsten Hopp |
26431a |
***************
|
|
Karsten Hopp |
26431a |
*** 1626,1631 ****
|
|
Karsten Hopp |
26431a |
--- 1474,1631 ----
|
|
Karsten Hopp |
26431a |
|
|
Karsten Hopp |
26431a |
#endif /* FEAT_CLIPBOARD */
|
|
Karsten Hopp |
26431a |
|
|
Karsten Hopp |
26431a |
+ #if defined(FEAT_MBYTE) || defined(PROTO)
|
|
Karsten Hopp |
26431a |
+ /*
|
|
Karsten Hopp |
26431a |
+ * Note: the following two functions are only guaranteed to work when using
|
|
Karsten Hopp |
26431a |
+ * valid MS-Windows codepages or when iconv() is available.
|
|
Karsten Hopp |
26431a |
+ */
|
|
Karsten Hopp |
26431a |
+
|
|
Karsten Hopp |
26431a |
+ /*
|
|
Karsten Hopp |
26431a |
+ * Convert "str" from 'encoding' to UTF-16.
|
|
Karsten Hopp |
26431a |
+ * Input in "str" with length "*lenp". When "lenp" is NULL, use strlen().
|
|
Karsten Hopp |
26431a |
+ * Output is returned as an allocated string. "*lenp" is set to the length of
|
|
Karsten Hopp |
26431a |
+ * the result. A trailing NUL is always added.
|
|
Karsten Hopp |
26431a |
+ * Returns NULL when out of memory.
|
|
Karsten Hopp |
26431a |
+ */
|
|
Karsten Hopp |
26431a |
+ short_u *
|
|
Karsten Hopp |
26431a |
+ enc_to_utf16(char_u *str, int *lenp)
|
|
Karsten Hopp |
26431a |
+ {
|
|
Karsten Hopp |
26431a |
+ vimconv_T conv;
|
|
Karsten Hopp |
26431a |
+ WCHAR *ret;
|
|
Karsten Hopp |
26431a |
+ char_u *allocbuf = NULL;
|
|
Karsten Hopp |
26431a |
+ int len_loc;
|
|
Karsten Hopp |
26431a |
+ int length;
|
|
Karsten Hopp |
26431a |
+
|
|
Karsten Hopp |
26431a |
+ if (lenp == NULL)
|
|
Karsten Hopp |
26431a |
+ {
|
|
Karsten Hopp |
26431a |
+ len_loc = (int)STRLEN(str) + 1;
|
|
Karsten Hopp |
26431a |
+ lenp = &len_loc;
|
|
Karsten Hopp |
26431a |
+ }
|
|
Karsten Hopp |
26431a |
+
|
|
Karsten Hopp |
26431a |
+ if (enc_codepage > 0)
|
|
Karsten Hopp |
26431a |
+ {
|
|
Karsten Hopp |
26431a |
+ /* We can do any CP### -> UTF-16 in one pass, and we can do it
|
|
Karsten Hopp |
26431a |
+ * without iconv() (convert_* may need iconv). */
|
|
Karsten Hopp |
26431a |
+ MultiByteToWideChar_alloc(enc_codepage, 0, str, *lenp, &ret, &length);
|
|
Karsten Hopp |
26431a |
+ }
|
|
Karsten Hopp |
26431a |
+ else
|
|
Karsten Hopp |
26431a |
+ {
|
|
Karsten Hopp |
26431a |
+ /* Use "latin1" by default, we might be called before we have p_enc
|
|
Karsten Hopp |
26431a |
+ * set up. Convert to utf-8 first, works better with iconv(). Does
|
|
Karsten Hopp |
26431a |
+ * nothing if 'encoding' is "utf-8". */
|
|
Karsten Hopp |
26431a |
+ conv.vc_type = CONV_NONE;
|
|
Karsten Hopp |
26431a |
+ if (convert_setup(&conv, p_enc ? p_enc : (char_u *)"latin1",
|
|
Karsten Hopp |
26431a |
+ (char_u *)"utf-8") == FAIL)
|
|
Karsten Hopp |
26431a |
+ return NULL;
|
|
Karsten Hopp |
26431a |
+ if (conv.vc_type != CONV_NONE)
|
|
Karsten Hopp |
26431a |
+ {
|
|
Karsten Hopp |
26431a |
+ str = allocbuf = string_convert(&conv, str, lenp);
|
|
Karsten Hopp |
26431a |
+ if (str == NULL)
|
|
Karsten Hopp |
26431a |
+ return NULL;
|
|
Karsten Hopp |
26431a |
+ }
|
|
Karsten Hopp |
26431a |
+ convert_setup(&conv, NULL, NULL);
|
|
Karsten Hopp |
26431a |
+
|
|
Karsten Hopp |
26431a |
+ length = utf8_to_utf16(str, *lenp, NULL, NULL);
|
|
Karsten Hopp |
26431a |
+ ret = (WCHAR *)alloc((unsigned)((length + 1) * sizeof(WCHAR)));
|
|
Karsten Hopp |
26431a |
+ if (ret != NULL)
|
|
Karsten Hopp |
26431a |
+ {
|
|
Karsten Hopp |
26431a |
+ utf8_to_utf16(str, *lenp, (short_u *)ret, NULL);
|
|
Karsten Hopp |
26431a |
+ ret[length] = 0;
|
|
Karsten Hopp |
26431a |
+ }
|
|
Karsten Hopp |
26431a |
+
|
|
Karsten Hopp |
26431a |
+ vim_free(allocbuf);
|
|
Karsten Hopp |
26431a |
+ }
|
|
Karsten Hopp |
26431a |
+
|
|
Karsten Hopp |
26431a |
+ *lenp = length;
|
|
Karsten Hopp |
26431a |
+ return (short_u *)ret;
|
|
Karsten Hopp |
26431a |
+ }
|
|
Karsten Hopp |
26431a |
+
|
|
Karsten Hopp |
26431a |
+ /*
|
|
Karsten Hopp |
26431a |
+ * Convert an UTF-16 string to 'encoding'.
|
|
Karsten Hopp |
26431a |
+ * Input in "str" with length (counted in wide characters) "*lenp". When
|
|
Karsten Hopp |
26431a |
+ * "lenp" is NULL, use wcslen().
|
|
Karsten Hopp |
26431a |
+ * Output is returned as an allocated string. If "*lenp" is not NULL it is
|
|
Karsten Hopp |
26431a |
+ * set to the length of the result.
|
|
Karsten Hopp |
26431a |
+ * Returns NULL when out of memory.
|
|
Karsten Hopp |
26431a |
+ */
|
|
Karsten Hopp |
26431a |
+ char_u *
|
|
Karsten Hopp |
26431a |
+ utf16_to_enc(short_u *str, int *lenp)
|
|
Karsten Hopp |
26431a |
+ {
|
|
Karsten Hopp |
26431a |
+ vimconv_T conv;
|
|
Karsten Hopp |
26431a |
+ char_u *utf8_str = NULL, *enc_str = NULL;
|
|
Karsten Hopp |
26431a |
+ int len_loc;
|
|
Karsten Hopp |
26431a |
+
|
|
Karsten Hopp |
26431a |
+ if (lenp == NULL)
|
|
Karsten Hopp |
26431a |
+ {
|
|
Karsten Hopp |
26431a |
+ len_loc = (int)wcslen(str) + 1;
|
|
Karsten Hopp |
26431a |
+ lenp = &len_loc;
|
|
Karsten Hopp |
26431a |
+ }
|
|
Karsten Hopp |
26431a |
+
|
|
Karsten Hopp |
26431a |
+ if (enc_codepage > 0)
|
|
Karsten Hopp |
26431a |
+ {
|
|
Karsten Hopp |
26431a |
+ /* We can do any UTF-16 -> CP### in one pass. */
|
|
Karsten Hopp |
26431a |
+ int length;
|
|
Karsten Hopp |
26431a |
+
|
|
Karsten Hopp |
26431a |
+ WideCharToMultiByte_alloc(enc_codepage, 0, str, *lenp,
|
|
Karsten Hopp |
26431a |
+ (LPSTR *)&enc_str, &length, 0, 0);
|
|
Karsten Hopp |
26431a |
+ *lenp = length;
|
|
Karsten Hopp |
26431a |
+ return enc_str;
|
|
Karsten Hopp |
26431a |
+ }
|
|
Karsten Hopp |
26431a |
+
|
|
Karsten Hopp |
26431a |
+ /* Avoid allocating zero bytes, it generates an error message. */
|
|
Karsten Hopp |
26431a |
+ utf8_str = alloc(utf16_to_utf8(str, *lenp == 0 ? 1 : *lenp, NULL));
|
|
Karsten Hopp |
26431a |
+ if (utf8_str != NULL)
|
|
Karsten Hopp |
26431a |
+ {
|
|
Karsten Hopp |
26431a |
+ *lenp = utf16_to_utf8(str, *lenp, utf8_str);
|
|
Karsten Hopp |
26431a |
+
|
|
Karsten Hopp |
26431a |
+ /* We might be called before we have p_enc set up. */
|
|
Karsten Hopp |
26431a |
+ conv.vc_type = CONV_NONE;
|
|
Karsten Hopp |
26431a |
+ convert_setup(&conv, (char_u *)"utf-8",
|
|
Karsten Hopp |
26431a |
+ p_enc? p_enc: (char_u *)"latin1");
|
|
Karsten Hopp |
26431a |
+ if (conv.vc_type == CONV_NONE)
|
|
Karsten Hopp |
26431a |
+ {
|
|
Karsten Hopp |
26431a |
+ /* p_enc is utf-8, so we're done. */
|
|
Karsten Hopp |
26431a |
+ enc_str = utf8_str;
|
|
Karsten Hopp |
26431a |
+ }
|
|
Karsten Hopp |
26431a |
+ else
|
|
Karsten Hopp |
26431a |
+ {
|
|
Karsten Hopp |
26431a |
+ enc_str = string_convert(&conv, utf8_str, lenp);
|
|
Karsten Hopp |
26431a |
+ vim_free(utf8_str);
|
|
Karsten Hopp |
26431a |
+ }
|
|
Karsten Hopp |
26431a |
+
|
|
Karsten Hopp |
26431a |
+ convert_setup(&conv, NULL, NULL);
|
|
Karsten Hopp |
26431a |
+ }
|
|
Karsten Hopp |
26431a |
+
|
|
Karsten Hopp |
26431a |
+ return enc_str;
|
|
Karsten Hopp |
26431a |
+ }
|
|
Karsten Hopp |
26431a |
+ #endif /* FEAT_MBYTE */
|
|
Karsten Hopp |
26431a |
+
|
|
Karsten Hopp |
26431a |
+ #if (defined(FEAT_MBYTE) && defined(WIN3264)) || defined(PROTO)
|
|
Karsten Hopp |
26431a |
+ /*
|
|
Karsten Hopp |
26431a |
+ * Convert from the active codepage to 'encoding'.
|
|
Karsten Hopp |
26431a |
+ * Input is "str[str_size]".
|
|
Karsten Hopp |
26431a |
+ * The result is in allocated memory: "out[outlen]". With terminating NUL.
|
|
Karsten Hopp |
26431a |
+ */
|
|
Karsten Hopp |
26431a |
+ void
|
|
Karsten Hopp |
26431a |
+ acp_to_enc(str, str_size, out, outlen)
|
|
Karsten Hopp |
26431a |
+ char_u *str;
|
|
Karsten Hopp |
26431a |
+ int str_size;
|
|
Karsten Hopp |
26431a |
+ char_u **out;
|
|
Karsten Hopp |
26431a |
+ int *outlen;
|
|
Karsten Hopp |
26431a |
+
|
|
Karsten Hopp |
26431a |
+ {
|
|
Karsten Hopp |
26431a |
+ LPWSTR widestr;
|
|
Karsten Hopp |
26431a |
+
|
|
Karsten Hopp |
26431a |
+ MultiByteToWideChar_alloc(GetACP(), 0, str, str_size, &widestr, outlen);
|
|
Karsten Hopp |
26431a |
+ if (widestr != NULL)
|
|
Karsten Hopp |
26431a |
+ {
|
|
Karsten Hopp |
26431a |
+ ++*outlen; /* Include the 0 after the string */
|
|
Karsten Hopp |
26431a |
+ *out = utf16_to_enc((short_u *)widestr, outlen);
|
|
Karsten Hopp |
26431a |
+ vim_free(widestr);
|
|
Karsten Hopp |
26431a |
+ }
|
|
Karsten Hopp |
26431a |
+ }
|
|
Karsten Hopp |
26431a |
+ #endif
|
|
Karsten Hopp |
26431a |
+
|
|
Karsten Hopp |
26431a |
|
|
Karsten Hopp |
26431a |
/*
|
|
Karsten Hopp |
26431a |
* Debugging helper: expose the MCH_WRITE_DUMP stuff to other modules
|
|
Karsten Hopp |
26431a |
*** ../vim-7.3.222/src/version.c 2011-06-19 01:27:29.000000000 +0200
|
|
Karsten Hopp |
26431a |
--- src/version.c 2011-06-19 01:28:41.000000000 +0200
|
|
Karsten Hopp |
26431a |
***************
|
|
Karsten Hopp |
26431a |
*** 711,712 ****
|
|
Karsten Hopp |
26431a |
--- 711,714 ----
|
|
Karsten Hopp |
26431a |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
26431a |
+ /**/
|
|
Karsten Hopp |
26431a |
+ 223,
|
|
Karsten Hopp |
26431a |
/**/
|
|
Karsten Hopp |
26431a |
|
|
Karsten Hopp |
26431a |
--
|
|
Karsten Hopp |
26431a |
hundred-and-one symptoms of being an internet addict:
|
|
Karsten Hopp |
26431a |
191. You rate eating establishments not by the quality of the food,
|
|
Karsten Hopp |
26431a |
but by the availability of electrical outlets for your PowerBook.
|
|
Karsten Hopp |
26431a |
|
|
Karsten Hopp |
26431a |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
26431a |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
26431a |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
Karsten Hopp |
26431a |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|