gpg: conversion from ‘utf-8’ to ‘US-ASCII’ failed: Illegal byte sequence
Today I was generating a new GPG key on my Mac (macOS High Sierra) and At the end of process I got a warning saying:
gpg: conversion from ‘utf-8’ to ‘US-ASCII’ failed: Illegal byte sequence
This warning appears because when I was providing my User ID information, I typed my Real Name with a non ASCII character: “Patrício dos Santos”.
By default GPG was using US-ASCII and conversion from “utf-8” to “US-ASCII” fails.
To fix it, you need to change the default character encoding to “utf-8” by create or edit the following file: “~/.gnupg/gpg.conf” :
$ nano ~/.gnupg/gpg.conf
And add the following line:
charset utf-8
That’s it. Now if you run “gpg –list-secret-keys –keyid-format LONG” the non ASCII characters will be displayed correctly.
Note that you will not be able to import a GPG with non ASCII characters if you don’t set utf-8 as the default.