summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xconfig-db/slxconfig-demuxer7
-rw-r--r--lib/OpenSLX/Utils.pm24
2 files changed, 23 insertions, 8 deletions
diff --git a/config-db/slxconfig-demuxer b/config-db/slxconfig-demuxer
index a57d3b50..f1cfd41e 100755
--- a/config-db/slxconfig-demuxer
+++ b/config-db/slxconfig-demuxer
@@ -382,6 +382,8 @@ sub writePXEMenus
$pxeTemplate .= slurpFile($pxeThemeConfig);
}
+print "$pxeTemplate\n";
+
# fetch info about margin and replace the corresponding placeholders
my $margin = $openslxConfig{'pxe-theme-menu-margin'} || 0;
my $marginAsText = ' ' x $margin;
@@ -450,10 +452,7 @@ sub writePXEMenus
# PXE uses 'cp850' (codepage 850) but our string is in utf-8, we have
# to convert in order to avoid showing gibberish on the client side...
- use Encode 'from_to';
- from_to($pxeConfig, 'utf-8', 'cp850');
-
- spitFile($pxeFile, $pxeConfig);
+ spitFile($pxeFile, $pxeConfig, { 'io-layer' => 'encoding(cp850)' } );
}
return;
}
diff --git a/lib/OpenSLX/Utils.pm b/lib/OpenSLX/Utils.pm
index fbfd8d4c..f3a13e48 100644
--- a/lib/OpenSLX/Utils.pm
+++ b/lib/OpenSLX/Utils.pm
@@ -100,13 +100,17 @@ sub slurpFile
my $fileName = shift || confess 'need to pass in fileName!';
my $flags = shift || {};
- checkParams($flags, { 'failIfMissing' => '?' });
+ checkParams($flags, {
+ 'failIfMissing' => '?',
+ 'io-layer' => '?',
+ });
my $failIfMissing
= exists $flags->{failIfMissing} ? $flags->{failIfMissing} : 1;
+ my $ioLayer = $flags->{'io-layer'} || 'utf8';
local $/;
my $fh;
- if (!open($fh, '<', $fileName)) {
+ if (!open($fh, "<:$ioLayer", $fileName)) {
return '' unless $failIfMissing;
croak _tr("could not open file '%s' for reading! (%s)", $fileName, $!);
}
@@ -120,9 +124,15 @@ sub spitFile
{
my $fileName = shift || croak 'need to pass in a fileName!';
my $content = shift;
+ my $flags = shift || {};
+
+ checkParams($flags, {
+ 'io-layer' => '?',
+ });
+ my $ioLayer = $flags->{'io-layer'} || 'utf8';
my $fh;
- open($fh, '>', $fileName)
+ open($fh, ">:$ioLayer", $fileName)
or croak _tr("unable to create file '%s' (%s)\n", $fileName, $!);
print $fh $content
or croak _tr("unable to print to file '%s' (%s)\n", $fileName, $!);
@@ -135,9 +145,15 @@ sub appendFile
{
my $fileName = shift || croak 'need to pass in a fileName!';
my $content = shift;
+ my $flags = shift || {};
+
+ checkParams($flags, {
+ 'io-layer' => '?',
+ });
+ my $ioLayer = $flags->{'io-layer'} || 'utf8';
my $fh;
- open($fh, '>>', $fileName)
+ open($fh, ">>:$ioLayer", $fileName)
or croak _tr("unable to create file '%s' (%s)\n", $fileName, $!);
print $fh $content
or croak _tr("unable to print to file '%s' (%s)\n", $fileName, $!);