diff options
| author | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2006-04-04 19:34:50 +0000 |
|---|---|---|
| committer | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2006-04-04 19:34:50 +0000 |
| commit | f50bd57bcebe08d26653299b189fe82beaea4a0f (patch) | |
| tree | abf11303982b8a1780667696347e554c55c6d907 /ikiwiki | |
| parent | a0321594fb72ab1d215204f1838d2593e0b24f95 (diff) | |
proper binmode settings so that with -CSD, ikiwiki will support unicode
however, due to robustness, that's not enabled by default yet
Diffstat (limited to 'ikiwiki')
| -rwxr-xr-x | ikiwiki | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -193,24 +193,27 @@ sub srcfile ($) { #{{{ error("internal error: $file cannot be found"); } #}}} -sub readfile ($) { #{{{ +sub readfile ($;$) { #{{{ my $file=shift; + my $binary=shift; if (-l $file) { error("cannot read a symlink ($file)"); } local $/=undef; - open (IN, "$file") || error("failed to read $file: $!"); + open (IN, $file) || error("failed to read $file: $!"); + binmode(IN) if $binary; my $ret=<IN>; close IN; return $ret; } #}}} -sub writefile ($$$) { #{{{ +sub writefile ($$$;$) { #{{{ my $file=shift; # can include subdirs my $destdir=shift; # directory to put file in my $content=shift; + my $binary=shift; my $test=$file; while (length $test) { @@ -232,6 +235,7 @@ sub writefile ($$$) { #{{{ } open (OUT, ">$destdir/$file") || error("failed to write $destdir/$file: $!"); + binmode(OUT) if $binary; print OUT $content; close OUT; } #}}} |
