"That's an odd encoding," I said to myself. "It must be UTF-8 presented
as ASCII or Windows-1252. Let's look, shall we?"
C:\Users\Robert J. Hansen\Desktop> gpg --fixed-list-mode --with-colons
--list-key 0x3ADBFA6D00A1E6FE > ludwig.asc
C:\Users\Robert J. Hansen\Desktop> python
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64
bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> with open("ludwig.asc") as fh:
... bytes = fh.read()
Weirder and weirder. GnuPG is outputting data in UTF-16LE, complete
with a correct byte-order mark... but is first taking what is
(apparently) the UTF-8 of Ludwig's name, giving each byte a null pair
byte, and calling it UTF-16.
Looking at the output from just a plain --list-key, it appears correct:
On Sat, Apr 01, 2017 at 04:57:04AM -0400, Robert J. Hansen wrote:
> C:\Users\Robert J. Hansen\Desktop> gpg --fixed-list-mode --with-colons
> --list-key 0x3ADBFA6D00A1E6FE
> [... trimmed ...]
> H├╝gelsch├ñfer <[hidden email]>:
> "That's an odd encoding," I said to myself. "It must be UTF-8 presented
> as ASCII or Windows-1252. Let's look, shall we?"
I've never noticed anything like that with Ludwig's key.
Either regularly or with the flags you used here. That said, if you
ever do need to be absolutely certain that the output is in UTF-8,
there is a way to guarantee it. Just use GPGME's little known or
noticed XML output with gpgme-tool:
The output will need to be trimmed of the GPGME header at the top, the
"OK" disconnection at the bottom, the "D " at the beginning of each
line and the "%0A" at the end of each line. I'm sure you can script
it to trim all that for you before writing the file anyway. Although
I've attached that example here.
On a semi-related note; a bit over a year ago I generated W3C XML
Schema (XSD) and Relax-NG Schema (RNG) files for the GPGME XML data.
From these I also generated Relax-NG Compact (RNC), DTDs, Docbook 5
documentation (from the XSD) and XHTML docs (from the Docbook); in
case anyone finds a need for validating the XML files. There isn't
currently a formal XML namespace setup for the schemas since it
doesn't appear that anyone's done anything with it (i.e. no one
noticed and thus no one asked for it).
Anyway, if they're of use, the schemas and docs are in one of my
branches on the git server, here:
I'd recommend using either the XSD or the RNG rather than the others.
They're generally going to be better or more accurate. The RNC and
DTD are there because I figured I may as well generate them at the