unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: forcing output to ASCII (from dealing with emoji glyphs :<)
Date: Mon, 27 Feb 2023 20:11:06 +0000	[thread overview]
Message-ID: <20230227201106.M120274@dcvr> (raw)

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	other threads:[~2023-02-27 20:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230227201106.M120274@dcvr \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).