Mercurial > vim
changeset 24711:788d7e3ade7c v8.2.2894
patch 8.2.2894: MS-Windows: using enc_locale() for strftime() might not work
Commit: https://github.com/vim/vim/commit/2c4a1d0a619b0f1e0f7dac98681da6fee58c6a44
Author: K.Takata <kentkt@csc.jp>
Date: Fri May 28 15:49:34 2021 +0200
patch 8.2.2894: MS-Windows: using enc_locale() for strftime() might not work
Problem: MS-Windows: using enc_locale() for strftime() might not work.
Solution: Use wcsftime(). (Ken Takata, closes https://github.com/vim/vim/issues/8271)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 28 May 2021 16:00:04 +0200 |
parents | 8e69a6ba0341 |
children | a2a1b64d088b |
files | src/time.c src/version.c |
diffstat | 2 files changed, 17 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/time.c +++ b/src/time.c @@ -252,7 +252,6 @@ f_reltimestr(typval_T *argvars UNUSED, t void f_strftime(typval_T *argvars, typval_T *rettv) { - char_u result_buf[256]; struct tm tmval; struct tm *curtime; time_t seconds; @@ -271,6 +270,20 @@ f_strftime(typval_T *argvars, typval_T * rettv->vval.v_string = vim_strsave((char_u *)_("(Invalid)")); else { +# ifdef MSWIN + WCHAR result_buf[256]; + WCHAR *wp; + + wp = enc_to_utf16(p, NULL); + if (wp != NULL) + (void)wcsftime(result_buf, sizeof(result_buf) / sizeof(WCHAR), + wp, curtime); + else + result_buf[0] = NUL; + rettv->vval.v_string = utf16_to_enc(result_buf, NULL); + vim_free(wp); +# else + char_u result_buf[256]; vimconv_T conv; char_u *enc; @@ -296,6 +309,7 @@ f_strftime(typval_T *argvars, typval_T * // Release conversion descriptors convert_setup(&conv, NULL, NULL); vim_free(enc); +# endif } } # endif