Subject: bug#79296: closed (Re: bug#79296: 30.2; format-time-string returns wrongly encoded string in MS Windows Japanese with cp65001 beta config)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 30 Aug 2025 09:26:02 +0000

Your bug report

#79296: 30.2; format-time-string returns wrongly encoded string in MS Windows Japanese with cp65001 beta config

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
79296: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=79296
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#79296: 30.2; format-time-string returns wrongly encoded string in MS Windows Japanese with cp65001 beta config
From: Eli Zaretskii <[email-masked]>
To: Shingo Tanaka <[email-masked]>
Cc: [email-masked], [email-masked], [email-masked], [email-masked], [email-masked]
Date: Sat, 30 Aug 2025 12:25:09 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> Date: Wed, 27 Aug 2025 22:54:30 +0900
> From: Shingo Tanaka <[email-masked]>
> Cc: Eli Zaretskii <[email-masked]>,
> 	[email-masked],
> 	[email-masked],
> 	[email-masked],
> 	[email-masked]
> 
> On Wed, 27 Aug 2025 18:05:42 +0900,
> Bruno Haible wrote:
> > 
> > For producing such binaries with only Free Software (no MSVC compiler,
> > no MSVC header files) one can use MSYS2. For a year or two already
> > it supports two target environments:
> >   - mingw-w64 with MSVCRT,
> >   - mingw-w64 with UCRT.
> > These two development environments are very similar, which means that
> > the Makefile will need very few adapations.
> 
> I've just installed MSYS2 Emacs of UCRT version and run it with no init file. 
> 
> ~> pacman -S mingw-w64-ucrt-x86_64-emacs
> ~> /ucrt64/bin/runemacs --no-init-file
> 
> And confirmed the issue I reported doesn't happen even with
> "Beta: Use Unicode UTF-8 for worldwide language support" on.
> 
> In *scratch* buffer:
> 
> (format-time-string "%y,%d,%m %A" (date-to-time (concat "2025,1,Jan")))
> "25,01,01 水曜日"
> 
> w32-system-coding-system
> cp65001
> 
> w32-multibyte-code-page
> 0
> 
> w32-ansi-code-page
> 65001
> 
> (w32-get-current-locale-id)
> 1041
> 
> (w32-get-locale-info (w32-get-current-locale-id))
> "JPN"
> 
> (w32-get-default-locale-id)
> 1041
> 
> (w32-get-locale-info (w32-get-default-locale-id))
> "JPN"
> 
> (w32-get-console-codepage)
> 65001
> 
> (w32-get-console-output-codepage)
> 65001

Thanks.  I've now added a new section to the Emacs w32 FAQ about these
issues, and I'm therefore closing this bug.

Subject: 30.2; format-time-string returns wrongly encoded string in MS Windows Japanese with cp65001 beta config
From: Shingo Tanaka <[email-masked]>
To: [email-masked]
Date: Sun, 24 Aug 2025 11:16:05 +0900
List-Id: <debbugs-submit.debbugs.gnu.org>

MS Windows has a utf-8 configuration with setting "Beta: Use Unicode UTF-8 for
worldwide language support" to on in its language settings.  In Japanese
environment, system coding is cp932 (MS version of Japanese SJIS) without the
setting but becomes cp65001 (utf-8) with the setting on.

Emacs looks like successfully detecting the change because locale-coding-system
gets from cp932 to cp65001 as expected, and working as expected overall.

However, I found a bug that format-time-string returns a day of the week string
encoded wrongly - with cp932 even in locale-coding-system is cp65001.

Conditions:
- Windows 11 Pro 24H2 with Japanese setting and "Beta: Use Unicode UTF-8
  for worldwide language support" on
- Emacs 30.2 (latest, https://ftp.gnu.org/gnu/emacs/windows/emacs-30/)

Here is how to reproduce.
1. Run Emacs with no-init-file
2. Go to *scratch* buffer and evaluate:
   (format-time-string "%y,%d,%m %A" (date-to-time (concat "2025,1,Jan")))
3. You will get below wrongly encoded string:
   "25,01,01 \220\205\227j\223\372"
4. evaluate:
   (decode-coding-string
    (format-time-string "%y,%d,%m %A" (date-to-time (concat "2025,1,Jan")))
    'cp932)
5. You will get below correctly decoded string:
   #("25,01,01 水曜日" 9 12 (charset cp932-2-byte))

This issue doesn't happen when "Beta: Use Unicode UTF-8 for worldwide language
support" off (locale-coding-system is cp932).

If you have any question or need further information, please let me know.

Regards,
Shingo