Page MenuHome GnuPG

Win32 console: non-ASCII file names output incorrectly
Open, NormalPublic

Description

Environment

Windows XP Professional Russian SP2
precompiled GPG

Description

Non-ascii directory/file names are shown incorrectly in messages like "gpg: keyring created '%filename' or national equivalent:
gpg: создана таблица ключей `C:/Documents and Settings/╦х°р/Application Data/gnupg\secring.gpg'
/╦х°р/ is in wrong encoding

How To Repeat

install fresh GPG on windows machine with username (home folder) written in non-ASCII.

Fix

WinXP uses different codepages to represent Unicode in console output and in file names:
OEMCP for console (e.g. DOS866 in Russia)
ANSICP for filenames (e.g. Win1251 in Russia)

To represent national file/dir names in console output correctly, something like
printf('File: %s',AnsiToOem(singlebyte_filename)) must be always used.

Event Timeline

We can't do much about it. Cluttering the code with W32
specific conversion routines is not an option.

There is nothing we can do about it right now. With
libestream it would be possible to do something about it.
The actual problem is that we can't use a static buffer for
converting the filename and allocating the memory is too
intrusive.

In principle, this can happen on Un*x systems, too. There is no guarantee about
the filesystem encoding. Glib has special interfaces for filename conversion
(G_FILENAME_ENCODING) to deal with this.

If gcc's print format checks would only support custom format string extesions
we could easily implement a filename specifier. Without that we are not able to
use format string checks which is something I don't want to miss.

We can do this with estream now.