Last active
December 21, 2015 06:58
-
-
Save tailriver/6267510 to your computer and use it in GitHub Desktop.
Windows + Strawberry Perl + Gnuplotでパイプ処理の場合に文字化けする例
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use utf8; | |
use File::Temp qw(tempfile); | |
my $xlabel = "時刻 [s]"; | |
my $ylabel = "振幅 [m]"; | |
my ($tgnuplot, $filename) = tempfile(); | |
binmode $tgnuplot, ':utf8'; | |
print $tgnuplot <<__EOM__; | |
set terminal pdfcairo noenhanced | |
set output 'sample_tempfile.pdf' | |
set xlabel '$xlabel' | |
set ylabel '$ylabel' | |
set xrange [-2*pi:2*pi] | |
plot sin(x) | |
unset output | |
__EOM__ | |
close $tgnuplot; | |
system "pgnuplot $filename"; | |
open my $pgnuplot, '|-:utf8', 'pgnuplot' or die $!; | |
print $pgnuplot <<__EOM__; | |
set terminal pdfcairo noenhanced | |
set output 'sample_pipe.pdf' | |
set xlabel '$xlabel' | |
set ylabel '$ylabel' | |
set xrange [-2*pi:2*pi] | |
plot sin(x) | |
unset output | |
__EOM__ | |
close $pgnuplot; | |
exit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
パイプを使ったとき、振幅と[m]の間にEのような文字が入る。