MIME-Q and MIME-Header will work the same for decoding, but the latter makes that easier to see. Signed-off-by: Thomas Hochstein <thh@thh.name>
26 lines
463 B
Perl
26 lines
463 B
Perl
#! /usr/bin/perl -w
|
|
#
|
|
# mew.pl
|
|
#
|
|
# converts from and to MIME encoded words
|
|
#
|
|
#
|
|
# Copyright (c) 2023 Thomas Hochstein <thh@thh.name>
|
|
|
|
use utf8;
|
|
use open qw(:std :encoding(UTF-8));
|
|
use Encode;
|
|
use MIME::QuotedPrint;
|
|
use MIME::Base64;
|
|
|
|
my $input = join (' ',@ARGV);
|
|
utf8::decode($input);
|
|
|
|
if ($input =~ /[\x80-\x{ffff}]/o) {
|
|
$output = encode('MIME-Q', $input);
|
|
$output =~ s/=20/_/g;
|
|
} else {
|
|
$output = decode('MIME-Header', $input);
|
|
};
|
|
|
|
print "$output\n";
|