X-Git-Url: http://git.ipfire.org/?p=people%2Fteissler%2Fipfire-2.x.git;a=blobdiff_plain;f=config%2Fcfgroot%2Fgeneral-functions.pl;fp=config%2Fcfgroot%2Fgeneral-functions.pl;h=41643d8d7451c25aebda2475600b0f9c170845a4;hp=3cdb36fbd4709229edd93b2f39893a145a17425f;hb=3e862ce4f99059002b60994addc87a013d298b38;hpb=f9dec458f39323bead4686f9e1a3bb827a9bd134 diff --git a/config/cfgroot/general-functions.pl b/config/cfgroot/general-functions.pl index 3cdb36fbd..41643d8d7 100644 --- a/config/cfgroot/general-functions.pl +++ b/config/cfgroot/general-functions.pl @@ -1030,4 +1030,27 @@ sub RedIsWireless() { return 0; } +# Function to read a file with UTF-8 charset. +sub read_file_utf8 ($) { + my ($file) = @_; + + open my $in, '<:encoding(UTF-8)', $file or die "Could not open '$file' for reading $!"; + local $/ = undef; + my $all = <$in>; + close $in; + + return $all; +} + +# Function to write a file with UTF-8 charset. +sub write_file_utf8 ($) { + my ($file, $content) = @_; + + open my $out, '>:encoding(UTF-8)', $file or die "Could not open '$file' for writing $!";; + print $out $content; + close $out; + + return; +} + 1;