From 276cb695cc544e3c536ef6adec357152e44bac1d Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sat, 29 Jul 2023 17:57:03 -0400 Subject: utf8ord: print utf-8 encoded hex bytes. --- utf8ord | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'utf8ord') 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 ""; } } -- cgit v1.2.3