Page MenuHome GnuPG

gpg 2.3+ may display garbled characters for date and time in non-English Windows
Closed, ResolvedPublic

Description

In gpg version 2.3, the setlocale (LC_TIME, ""); function was added for the Windows platform to display the corresponding format and language based on user settings. However, in non-English Windows such as Chinese, the Unicode characters included in the date and time may become garbled.

According to the[[ https://learn.microsoft.com/zh-tw/cpp/c-runtime-library/reference/setlocale-wsetlocale?view=msvc-170#utf-8-support | Microsoft documentation ]], starting from Windows 10 version 1803 (10.0.17134.0), setlocale(LC_ALL, ".UTF8") can use the current default Windows ANSI code page (ACP) for the locale and UTF-8 for the code page.

Suggestion:
It is recommended to change the code from asctimestamp (u32 stamp) / # if HAVE_W32_SYSTEM / setlocale(LC_TIME, "") to setlocale(LC_TIME, ".UTF8").

Details

Version
2.4.3

Event Timeline

werner added projects: gnupg24, Windows.
werner added a subscriber: werner.

Thanks for the report and the helpful suggestion. I was anyway about to change the time format but your suggestion is better.

Do you have any hint how I can test this? I installed Chinese-Simplified (zh_CN) but I fear switching the display Language. Maybe I should just use _wasctime and convert to utf8

werner triaged this task as Normal priority.Oct 6 2023, 11:27 AM
werner added a project: i18n.

Here is my code to test differences between setlocale(LC_TIME, ".UTF8") and setlocale(LC_TIME, "") and the results on English, Japanese and Korea Windows.

I think ".UTF8" is always better than LC_TIME="" if the display string contains non-English Unicode chars.

werner changed the task status from Open to Testing.Oct 27 2023, 2:23 PM
werner moved this task from Backlog to QA on the gnupg24 board.

No regression, assuming things work.