G'day Perlian,

Here's a generic technique for dealing with this type of problem which doesn't require listing every character.

$ perl -Mutf8 -C -E '
    my ($offset_0, $offset_A, $offset_a)
        = (ord("𝟎")-ord("0"), ord("𝐀")-ord("A"), ord("𝐚")-ord("a"));
    say "The quick brown fox jumps over the lazy dog 1234567890 times."
        =~ s/([0-9])/chr(ord($1)+$offset_0)/egr
        =~ s/([A-Z])/chr(ord($1)+$offset_A)/egr
        =~ s/([a-z])/chr(ord($1)+$offset_a)/egr;
'
𝐓𝐡𝐞 𝐪𝐮𝐢𝐜𝐤 𝐛𝐫𝐨𝐰𝐧 𝐟𝐨𝐱 𝐣𝐮𝐦𝐩𝐬 𝐨𝐯𝐞𝐫 𝐭𝐡𝐞 𝐥𝐚𝐳𝐲 𝐝𝐨𝐠 𝟏𝟐𝟑𝟒𝟓𝟔𝟕𝟖𝟗𝟎 𝐭𝐢𝐦𝐞𝐬.

This should work fine with your 5.26.3 (I'm using 5.32.0). As general information: say requires 5.10 and /r requires 5.14.

Two caveats:

Here's another example to show the generality of the solution. Only three characters were changed in the code to produce completely different output.

$ perl -Mutf8 -C -E '
    my ($offset_0, $offset_A, $offset_a)
        = (ord("𝟘")-ord("0"), ord("𝕬")-ord("A"), ord("𝖆")-ord("a"));
    say "The quick brown fox jumps over the lazy dog 1234567890 times."
        =~ s/([0-9])/chr(ord($1)+$offset_0)/egr
        =~ s/([A-Z])/chr(ord($1)+$offset_A)/egr
        =~ s/([a-z])/chr(ord($1)+$offset_a)/egr;
'
𝕿𝖍𝖊 𝖖𝖚𝖎𝖈𝖐 𝖇𝖗𝖔𝖜𝖓 𝖋𝖔𝖝 𝖏𝖚𝖒𝖕𝖘 𝖔𝖛𝖊𝖗 𝖙𝖍𝖊 𝖑𝖆𝖟𝖞 𝖉𝖔𝖌 𝟙𝟚𝟛𝟜𝟝𝟞𝟟𝟠𝟡𝟘 𝖙𝖎𝖒𝖊𝖘.

— Ken


In reply to Re: Transform ASCII into UniCode by kcott
in thread Transform ASCII into UniCode by Perlian

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.