Skip to content

Commit

Permalink
patch 8.0.1835: print document name does not support multi-byte
Browse files Browse the repository at this point in the history
Problem:    Print document name does not support multi-byte.
Solution:   Use StartDocW() if needed. (Yasuhiro Matsumoto, closes #2478)
  • Loading branch information
brammool committed May 13, 2018
1 parent 518bc17 commit 2290b1f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
31 changes: 26 additions & 5 deletions src/os_mswin.c
Expand Up @@ -1678,19 +1678,40 @@ mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit)
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);
SetAbortProc(prt_dlg.hDC, AbortProc);
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). */
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -761,6 +761,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1835,
/**/
1834,
/**/
Expand Down

0 comments on commit 2290b1f

Please sign in to comment.