* forcing output to ASCII (from dealing with emoji glyphs :<)
@ 2023-02-27 20:11 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2023-02-27 20:11 UTC (permalink / raw)
To: meta
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__
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-02-27 20:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-27 20:11 forcing output to ASCII (from dealing with emoji glyphs :<) Eric Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).