New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows で印刷する際のドキュメント名が文字化けする #1132

Closed
mattn opened this Issue Dec 20, 2017 · 4 comments

Comments

Projects
None yet
2 participants
@mattn
Member

mattn commented Dec 20, 2017

以前から発生していた。

おそらく複合機などを使っている人だとスプーラの画面に出てくるドキュメント名が文字化けしているはず。

diff --git a/src/os_mswin.c b/src/os_mswin.c
index ef756421f..9abdea2c0 100644
--- a/src/os_mswin.c
+++ b/src/os_mswin.c
@@ -1679,8 +1679,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);
@@ -1688,10 +1690,30 @@ mch_print_begin(prt_settings_T *psettings)
     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(DOCINFO));
+	di.cbSize = sizeof(DOCINFO);
+	di.lpszDocName = wp;
+	ret = StartDocW(prt_dlg.hDC, &di);
+	vim_free(wp);
+    }
+    else
+#endif
+    {
+	DOCINFO		di;
+	vim_memset(&di, 0, sizeof(DOCINFO));
+	di.cbSize = sizeof(DOCINFO);
+	di.lpszDocName = (LPCSTR)psettings->jobname;
+	ret = StartDoc(prt_dlg.hDC, &di);
+    }
+
 
 #ifdef FEAT_GUI
     /* Give focus back to main window (when using MDI). */
@mattn

This comment has been minimized.

Show comment
Hide comment
@mattn
Member

mattn commented Dec 20, 2017

@mattn

This comment has been minimized.

Show comment
Hide comment
@mattn

mattn Dec 20, 2017

Member

構造体サイズが違う

Member

mattn commented Dec 20, 2017

構造体サイズが違う

@k-takata

This comment has been minimized.

Show comment
Hide comment
@k-takata

k-takata Dec 21, 2017

Member

sizeof(di) の方がミスを起こしにくいかも。

Member

k-takata commented Dec 21, 2017

sizeof(di) の方がミスを起こしにくいかも。

@k-takata

This comment has been minimized.

Show comment
Hide comment
@k-takata

k-takata May 15, 2018

Member

Fixed by 8.0.1835: vim/vim@2290b1f

Member

k-takata commented May 15, 2018

Fixed by 8.0.1835: vim/vim@2290b1f

@k-takata k-takata closed this May 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment