aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/Utils.pm
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-10-10 14:50:30 +0100
committerStruan Donald <struan@exo.org.uk>2011-10-10 14:50:30 +0100
commit6e7276b843fde5e0490c3859f4beb92538004c0e (patch)
tree51bbf37602f6f3c6c83eae8a80e22a5a99c49194 /perllib/Utils.pm
parenta8b2d90c78103024b58b1760db72ab5c9397511b (diff)
parent5eb4f4e746283b4e945b52745503baa4da4f345f (diff)
Merge remote branch 'origin/master' into open311-consumer
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;