diff options
author | B. Watson <urchlay@slackware.uk> | 2023-07-29 17:57:03 -0400 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2023-07-29 17:57:03 -0400 |
commit | 276cb695cc544e3c536ef6adec357152e44bac1d (patch) | |
tree | 05365aeb645a1904f0375da9ac1329bcc63738c3 | |
parent | d1134cdf9e967f37a172dfc779ad6b9adf43fc43 (diff) | |
download | misc-scripts-276cb695cc544e3c536ef6adec357152e44bac1d.tar.gz |
utf8ord: print utf-8 encoded hex bytes.
-rwxr-xr-x | utf8ord | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -7,6 +7,14 @@ use charnames qw/:full/; for(@ARGV) { for(split "") { my $c = ord; - printf("%s\t%d\t%04x\t%s\n", $_, $c, $c, charnames::viacode($c)) for split ""; + my $hex = ""; + my @bytes; + { + use bytes; + @bytes = split //; + @bytes = map { sprintf("%02x", ord) } @bytes; + $hex = join(",", @bytes); + } + printf("%s\t%d\t%04x\t$hex\t%s\n", $_, $c, $c, charnames::viacode($c)) for split ""; } } |