aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/Utils.pm
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-09-20 16:13:15 +0100
committerStruan Donald <struan@exo.org.uk>2011-09-20 16:13:15 +0100
commit6128a2790b682170d2cac4b4674b4ac3ac2dc517 (patch)
tree63b493b3d442db2078c7fbf1b96afc7d275ef1ba /perllib/Utils.pm
parentdd82abb2c31d77fbd54799f08322ee074f46a160 (diff)
parent77f31e8c96c727ea5ab9cf217cfd924074e8f3ed (diff)
Merge remote branch 'origin/master' into rss-addresses
Diffstat (limited to 'perllib/Utils.pm')
-rw-r--r--perllib/Utils.pm14
1 files changed, 14 insertions, 0 deletions
diff --git a/perllib/Utils.pm b/perllib/Utils.pm
index c9afff186..954561a08 100644
--- a/perllib/Utils.pm
+++ b/perllib/Utils.pm
@@ -13,6 +13,7 @@ package Utils;
use strict;
use Encode;
+use File::Slurp qw();
use POSIX qw(strftime);
use mySociety::DBHandle qw(dbh);
use mySociety::GeoUtil;
@@ -262,4 +263,17 @@ sub _part {
}
}
+=head2 read_file
+
+Reads in a UTF-8 encoded file using File::Slurp and decodes it from UTF-8.
+This appears simplest, rather than getting confused with binmodes and so on.
+
+=cut
+sub read_file {
+ my $filename = shift;
+ my $data = File::Slurp::read_file( $filename );
+ $data = Encode::decode( 'utf8', $data );
+ return $data;
+}
+
1;