I've had the unfortunate experience of having to deal with some
emoji in emails.  The lack of glyphs which work in a text terminal
meant I needed to take extra steps to understand the message.

In the WWW output, the HTML is always ASCII and I can run
`perl -mcharnames -E "say charnames::viacode(shift)" $CODE'
after switching to source view in w3m to get the entity code.

For lei, I'm thinking an `--ascii' flag could be added to
`lei q -f (text|reply)' to support this.  Or I can keep piping
messages to the script below.  *shrug*

-------8<--------
eval 'exec perl -w -S $0 ${1+"$@"}'
if 0; # running under some shell
use v5.12; # newer versions have the latest Unicode chars
use charnames ();
use Encode qw(find_encoding);
binmode STDIN, ':utf8';
binmode STDOUT, ':utf8';
my $enc_ascii = find_encoding('us-ascii');
my $fallback = sub {
        join('', map {
                if ($_ == 0xfe0f) { # VARIATION SELECTOR-16
                        '';
                } elsif (defined(my $name = charnames::viacode($_))) {
                        "<$name>";
                } else {
                        sprintf('<0x%x>', $_);
                }
        } @_);
};
while (<STDIN>) { print $enc_ascii->encode($_, $fallback) }
__END__

Reply via email to