country.pl: load iso 3166 country codes file as UTF8

This file is UTF-8 encoded and contains Unicode characters for encoding
country names, such as "Åland Islands" for example.

Otherwise, the final locale-info.json that gets shipped with the ISO
might contain wrongly-encoded country names, causing display errors in
(at least) the GTK installer country dropdown.

Reported-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
Reviewed-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
Tested-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
Link: https://lore.proxmox.com/20250408084750.161399-1-c.heiss@proxmox.com
This commit is contained in:
Christoph Heiss 2025-04-08 10:47:43 +02:00 committed by Thomas Lamprecht
parent bd93189d83
commit 4b5db269ec

View File

@ -88,7 +88,7 @@ my sub parse_zoneinfo {
# country codes from:
my $country_codes_file = "/usr/share/iso-codes/json/iso_3166-1.json";
my $iso_3166_codes = from_json(PVE::Tools::file_get_contents($country_codes_file, 64 * 1024));
my $iso_3166_codes = from_json(PVE::Tools::file_get_contents($country_codes_file, 64 * 1024), { utf8 => 1 });
my $country_codes = { map { lc($_->{'alpha_2'}) => $_->{'common_name'} // $_->{'name'} } @{$iso_3166_codes->{'3166-1'}} };