changeset 13929:05aec5ac9630 v8.0.1835

patch 8.0.1835: print document name does not support multi-byte commit https://github.com/vim/vim/commit/2290b1f8aaafbcb38bd801d08e8bf86cb07abfa5 Author: Bram Moolenaar <Bram@vim.org> Date: Sun May 13 17:30:45 2018 +0200 patch 8.0.1835: print document name does not support multi-byte Problem: Print document name does not support multi-byte. Solution: Use StartDocW() if needed. (Yasuhiro Matsumoto, closes https://github.com/vim/vim/issues/2478)
author Christian Brabandt <cb@256bit.org>
date Sun, 13 May 2018 17:45:05 +0200
parents 9b53f97f532c
children a875da38f3cf
files src/os_mswin.c src/version.c
diffstat 2 files changed, 28 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/os_mswin.c
+++ b/src/os_mswin.c
@@ -1678,8 +1678,10 @@ init_fail_dlg:
 mch_print_begin(prt_settings_T *psettings)
 {
     int			ret;
-    static DOCINFO	di;
     char		szBuffer[300];
+#if defined(FEAT_MBYTE)
+    WCHAR		*wp = NULL;
+#endif
 
     hDlgPrint = CreateDialog(GetModuleHandle(NULL), TEXT("PrintDlgBox"),
 					     prt_dlg.hwndOwner, PrintDlgProc);
@@ -1687,10 +1689,29 @@ mch_print_begin(prt_settings_T *psetting
     wsprintf(szBuffer, _("Printing '%s'"), gettail(psettings->jobname));
     vimSetDlgItemText(hDlgPrint, IDC_PRINTTEXT1, (char_u *)szBuffer);
 
-    vim_memset(&di, 0, sizeof(DOCINFO));
-    di.cbSize = sizeof(DOCINFO);
-    di.lpszDocName = (LPCSTR)psettings->jobname;
-    ret = StartDoc(prt_dlg.hDC, &di);
+#if defined(FEAT_MBYTE)
+    if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+	wp = enc_to_utf16(psettings->jobname, NULL);
+    if (wp != NULL)
+    {
+	DOCINFOW	di;
+
+	vim_memset(&di, 0, sizeof(di));
+	di.cbSize = sizeof(di);
+	di.lpszDocName = wp;
+	ret = StartDocW(prt_dlg.hDC, &di);
+	vim_free(wp);
+    }
+    else
+#endif
+    {
+	DOCINFO		di;
+
+	vim_memset(&di, 0, sizeof(di));
+	di.cbSize = sizeof(di);
+	di.lpszDocName = (LPCSTR)psettings->jobname;
+	ret = StartDoc(prt_dlg.hDC, &di);
+    }
 
 #ifdef FEAT_GUI
     /* Give focus back to main window (when using MDI). */
--- a/src/version.c
+++ b/src/version.c
@@ -762,6 +762,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1835,
+/**/
     1834,
 /**/
     1833,