in reply to Transform ASCII into UniCode

a comment rather than an answer. Consider:

use strict; use warnings; use Encode; binmode *STDOUT, 'utf8'; # Suppress "wide character" warnings my $CharSet = 'a'; # ASCII my $BoldSet = pack('U', 119834); # Unicode bold 'a' my $Source = 'a'; my $trTarget = $Source; my $reTarget = $Source; $trTarget =~ tr/$CharSet/$BoldSet/; $reTarget =~ s/$CharSet/$BoldSet/; print "$Source\n$trTarget\n$reTarget\n"; print $BoldSet;

Prints:

a l 𝐚 𝐚

It seems tr/// isn't the right tool for the job. :-(

Update: PerlMonks is screwing up the unicode characters. They render correctly when I paste them into the edit window, but are shown as code points when I submit the edit. Bugger.

Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

Replies are listed 'Best First'.
Re^2: Transform ASCII into UniCode
by Anonymous Monk on Mar 23, 2021 at 09:00 UTC