Okay, this is silly and I probably could have found a better way to spend the last couple hours but I was curious and surprised by Text::Unidecode’s lack of efficacy here so… (has to be <pre/> instead of <code/> tags because of content.)

Posting it because I do these things so rarely I’ll lose the memory of how to do it if I don’t. :P

#!/usr/bin/env perl
use 5.14.0; # Not sure this is earliest/best.
use utf8;
use strictures;
use open ":std", ":encoding(utf8)";
use Unicode::UCD "charinfo";
use charnames ":full";
use YAML; # For introspection if you're curious.

my @sex_and_porn = <DATA>;

for my $sap ( @sex_and_porn )
{
    chomp $sap;
    my @string;
    for my $chr ( split "", $sap )
    {
        next unless $chr =~ /\A[[:print:]]+\z/;
        my $info = charinfo(ord($chr));
        # print Dump($info);
        my $name = $info->{name};
        next if $name =~ /COMBINING/;
        my $replacement;
        if ( $name =~ /\b(SMALL|CAPITAL)?(?: LETTER)?(?: TURNED| SHARP)? ([A-Z])\b/ )
        {
            no warnings "uninitialized";
            my $case = $1 eq "SMALL" ? "SMALL" : "CAPITAL";
            $replacement = "LATIN $case LETTER $2";
        }

        my $final = charnames::string_vianame( $replacement || $name );

        push @string, $final =~ /(?:\b[A-Z]\b| )/i ?
            $final : "\x{0}";
    }
    s/\x{0}+/[?]/g for @string;
    printf " %15s -> %s\n\n", $sap, join "", @string;
}

__DATA__
s3x & pr0n
s̸͚͍̺̺͇̝̥͎͕̃e̸̲͆̅̈́̈̈́̆͆̀͆͘͜x̶̧̟̭̘̿̂̈́͝ ̷̨͇͓͖̅̄͑̓̕͝a̵̰̜̣͎͔͛͗̆̋̓n̸͍̳͍̤̊́͌͌͗͂͘d̵͇̱̣̈́̀͒͆̐͠͝ ̷̡͓̥̙͕̦͙̬̠͒̐ͅp̶̡̖̫̱̞̙͔͑̊͛͌̈́͘ô̷̫̰̫̹̘̖̪͙͌͋͗̓̓̂̿r̴͎͇͖̲̦̤͕̉n̸̘̝͇͌̂͒̈́͝
รєא คภ๔ ק๏гภ
ˢᵉˣ ᵃⁿᵈ ᵖᵒʳⁿ
𝚜𝚎𝚡 𝚊𝚗𝚍 𝚙𝚘𝚛𝚗
uɹod puɐ xǝs
🅂🄴🅇 🄰🄽🄳 🄿🄾🅁🄽
🎀 𝓈𝑒𝓍 𝒶𝓃𝒹 𝓅🍑𝓇𝓃 🎀
𝘀𝗲𝘅 𝗮𝗻𝗱 𝗽𝗼𝗿𝗻 
ßêx and pørñ
ẞӬ𐊜 AƝḊ ⓅỚℝꞐ

Output–

      s3x & pr0n -> s[?]x [?] pr[?]n

 s̸͚͍̺̺͇̝̥͎͕̃e̸̲͆̅̈́̈̈́̆͆̀͆͘͜x̶̧̟̭̘̿̂̈́͝ ̷̨͇͓͖̅̄͑̓̕͝a̵̰̜̣͎͔͛͗̆̋̓n̸͍̳͍̤̊́͌͌͗͂͘d̵͇̱̣̈́̀͒͆̐͠͝ ̷̡͓̥̙͕̦͙̬̠͒̐ͅp̶̡̖̫̱̞̙͔͑̊͛͌̈́͘ô̷̫̰̫̹̘̖̪͙͌͋͗̓̓̂̿r̴͎͇͖̲̦̤͕̉n̸̘̝͇͌̂͒̈́͝ -> sex and porn

    รєא คภ๔ ק๏гภ -> [?][?][?] [?][?][?] [?][?][?][?]

    ˢᵉˣ ᵃⁿᵈ ᵖᵒʳⁿ -> sex and porn

    𝚜𝚎𝚡 𝚊𝚗𝚍 𝚙𝚘𝚛𝚗 -> sex and porn

    uɹod puɐ xǝs -> urod pua xes

    🅂🄴🅇 🄰🄽🄳 🄿🄾🅁🄽 -> SEX AND PORN

 🎀 𝓈𝑒𝓍 𝒶𝓃𝒹 𝓅🍑𝓇𝓃 🎀 -> [?] sex and p[?]rn [?]

   𝘀𝗲𝘅 𝗮𝗻𝗱 𝗽𝗼𝗿𝗻  -> sex and porn 

    ßêx and pørñ -> sex and porn

    ẞӬ𐊜 AƝḊ ⓅỚℝꞐ -> SEX AND PORN


In reply to Re^3: Bad Language In Contact Messages by Your Mother
in thread Bad Language In Contact Messages by Milti

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.