From 38a3d62f00e423d6eb47eb6c7b124c9320eca2b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Wr=C3=B3bel?= Date: Sun, 23 Jun 2019 19:51:21 -0400 Subject: [PATCH] Check and UTF8-encode the names if needed Fixes the "Wide character in subroutine entry" error for some UTF8 entries --- util/obfuscate.pl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util/obfuscate.pl b/util/obfuscate.pl index a0d2ecf690..e1e97ff719 100755 --- a/util/obfuscate.pl +++ b/util/obfuscate.pl @@ -6,6 +6,8 @@ use strict; use warnings; +use utf8; +use Encode; use Digest::MD5 qw(md5_hex); use XML::DOM; # on ubuntu this requires 'libxml-dom-perl' @@ -32,7 +34,8 @@ close DICT; sub get_a_name { my $scalar = shift; return '' if !$scalar; - my $index = hex substr(md5_hex($scalar),-$hex_digits); + my $scalar_encoded = utf8::is_utf8($scalar) ? Encode::encode_utf8($scalar) : $scalar; + my $index = hex substr(md5_hex($scalar_encoded),-$hex_digits); my $result = $dict[$index]; chop $result; return $result;