misc/bin/wide

20 lines
436 B
Text
Raw Normal View History

2022-05-20 05:54:47 -04:00
#!/usr/bin/env raku
#| convert arguments or stdin to fullwidth characters
unit sub MAIN(*@args);
sub widen(Str $str) {
my %map = (['!'..'~'] Z [''..'']).Map, ' ' => ' ';
my @rejects = $str.comb.grep: {$^x !~~ /\s/ && $^x ∉ %map};
note "unknown characters: @rejects.join(', ')" if @rejects;
$str.trans: %map
}
if @args > 0 {
say widen @args.join: ' '
} else {
say widen $_ for $*IN.lines
}
2022-05-20 06:44:13 -04:00
# vim: set ft=raku :