Skip to content

Instantly share code, notes, and snippets.

@tailriver
Last active December 21, 2015 06:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tailriver/6267510 to your computer and use it in GitHub Desktop.
Save tailriver/6267510 to your computer and use it in GitHub Desktop.
Windows + Strawberry Perl + Gnuplotでパイプ処理の場合に文字化けする例
#!/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;
@tailriver
Copy link
Author

パイプを使ったとき、振幅と[m]の間にEのような文字が入る。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment