The character set is chosen to be suitable for pathnames, and the same as that used by contrib/nmbug [With additions by Jani Nikula]