aboutsummaryrefslogtreecommitdiff
path: root/utf8ord
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2023-07-29 17:57:03 -0400
committerB. Watson <urchlay@slackware.uk>2023-07-29 17:57:03 -0400
commit276cb695cc544e3c536ef6adec357152e44bac1d (patch)
tree05365aeb645a1904f0375da9ac1329bcc63738c3 /utf8ord
parentd1134cdf9e967f37a172dfc779ad6b9adf43fc43 (diff)
downloadmisc-scripts-276cb695cc544e3c536ef6adec357152e44bac1d.tar.gz
utf8ord: print utf-8 encoded hex bytes.
Diffstat (limited to 'utf8ord')
-rwxr-xr-xutf8ord10
1 files changed, 9 insertions, 1 deletions
diff --git a/utf8ord b/utf8ord
index f413906..de0b6c5 100755
--- a/utf8ord
+++ b/utf8ord
@@ -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 "";
}
}