Subject: bug#71500: 28.2; Can't create/open .gpg file name contains non-ascii encoding in windows

From: Eli Zaretskii <[email-masked]>
Date: Wed, 12 Jun 2024 10:52:23 +0300

> From: Tatsuya Kumazawa <[email-masked]>
> Date: Tue, 11 Jun 2024 22:35:23 +0900
> 
> When I save .gpg file contains non-ASCII(eg: e:/あ.gpg).
> 
> I got message below
> (It happens anytime when user name contains non-ASCII
> (it must to change epg-gpg-home-directory to ASCII only path))
> 
> ----
> Error while encrypting with "e:/msys2/usr/bin/gpg.exe":
> 
> gpg: can't create 'c:/Users/(my name with CP932 encoded by
> UTF-8)/AppData/Local/Temp/epg-output9UGAFQ': No such file or directory
> gpg: symmetric encryption of '[stdin]' failed: No such file or directory
> ----
> 
> 
> When I open e:/あ.gpg, I got
> 
> ----
> Error while decrypting with "e:/msys2/usr/bin/gpg.exe":
> 
> gpg: can't open 'e:/邵ｺ繝ｻgpg': No such file or directory
> gpg: decrypt_message failed: No such file or directory
> ----
> 
> It seems UTF-8 encode by CP932 binary sequence.
> 
> share\emacs\28.2\lisp\epg.el
> 
> 673:                                                     :coding 'raw-text
> 
> to
> 
> 673:                                                     :coding
> '(raw-text . cp932)
> 
> (CP932 is japanese charactor code of windows)
> seemsly worked in my environment.
> 
> 
> 
> It might be good from cp932 to system process encoding for multilanguage?

There were some encoding problems in epg that were fixed recently in
the development sources.  Can try Emacs 30 from the master branch of
the Emacs Git repository and see if the problem still exists there?

In any case, on MS-Windows Emacs can only support GPG-encoding of file
names that can be encoded in your system codepage, due to limitations
of how Emacs on Windows invokes sub-processes.  So this will only work
of cp932 is your system codepage.