On Thu, Jul 1, 2021 at 7:50 PM Yuki Kimoto <kimoto.yuki@gmail.com> wrote: > > 2021-7-2 1:52 Dan Book <grinnz@gmail.com> wrote: > >> On Thu, Jul 1, 2021 at 12:46 PM Paul "LeoNerd" Evans < >> leonerd@leonerd.org.uk> wrote: >> >>> Consider >>> >>> printf "%-40s : %s\n", $_->@* for @rows; >>> >>> There is one potential problem here: you normally need to encode >> characters to bytes in order to print them. The grapheme determination >> would need to happen before encoding. This would work out if you're >> printing to a handle with an encoding layer, but probably cause confusion >> in the usual case. >> >> -Dan >> > > Does the following code work well? > > use utf8; > use Encode 'encode'; > > my $ouptput = ''; > > for my $row (@rows) { > $ouptput .= sprintf "あいうえお %-|40s : %s\n", $row->@*; > } > > print encode('UTF-8', $output); > > Yes, encoding after this operation is done with sprintf would work fine. The documentation could explain this. -DanThread Previous