From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 4C61B1F47D; Mon, 27 Feb 2023 20:11:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1677528666; bh=3bLxBJ2w8rpUcqovdRjYs9K3Kx6WrHwEe9YH/IzsMoQ=; h=Date:From:To:Subject:From; b=GlpaQosvEvVpZcgmwCSNaw54qmgM0+QPKAEWHu79X7naFc6ZWeA+45WwN8oW7lN/d wxpI0XUFBZDyJWA01GJ/AAibkOX4tG6fcnyQQ29R5n7ld1EzpC8CWqXnVrSFPuUWqs y5T4P4W1RM6GEubLcxBBadbaRdoCdxPd0BbbnYHw= Date: Mon, 27 Feb 2023 20:11:06 +0000 From: Eric Wong To: meta@public-inbox.org Subject: forcing output to ASCII (from dealing with emoji glyphs :<) Message-ID: <20230227201106.M120274@dcvr> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline List-Id: 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 () { print $enc_ascii->encode($_, $fallback) } __END__