Subject: | Patch to add FIPS codes for UK |
The attached patch adds support for United Kingdom FIPS 10-4 codes. I
used the following Perl code to modify SubCountry.pm (I'm attaching here
in case it is useful to someone else how wants to add FIPS codes for
another country)
my %fips;
# UKFIPS is CSV version of data from this page:
http://www.statoids.com/ugb.html
open my $fh, "UKFIPS.csv";
while (<$fh>) {
s!"!!g;
my ($iso, $fips) = split(",");
print "$iso -> $fips\n";
$fips =~ s!^UK!!;
$fips{$iso} = $fips;
}
open my $fh, "/usr/lib/perl5/site_perl/5.8.7/Locale/SubCountry.pm";
open my $out, ">SubCountry.pm";
my $in_uk;
while (<$fh>) {
print $out $_;
if (m!<name>UNITED KINGDOM</name>!) {
$in_uk = 1;
}
if (m!</country>!) {
$in_uk = 0;
}
if ($in_uk) {
if (m!<code>(\w+)</code>!) {
my $fips = $fips{$1};
if ($fips) {
print $out " <FIPS>$fips</FIPS>\n";
}
}
}
}
Subject: | fips_uk.patch |
Message body is not shown because it is too large.