in reply to Transform ASCII into UniCode

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