diff options
-rwxr-xr-x | localworddiff | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/localworddiff b/localworddiff index 1561684..af29599 100755 --- a/localworddiff +++ b/localworddiff @@ -33,14 +33,18 @@ my ( $infile1, $infile2, $outfile ) = @ARGV; die 'Missing input file arguments' unless ( $infile1 and $infile2 ); +# read infiles using File::Slurp (Text::WordDiff don't handle UTF-8) +my $text1 = read_file( $infile1, binmode => ':utf8' ); +my $text2 = read_file( $infile2, binmode => ':utf8' ); + # use console if no output file provided as third argument unless ($outfile) { - print word_diff $infile1, $infile2, { STYLE => 'ANSIColor' }; + print word_diff $text1, $text2, { STYLE => 'ANSIColor' }; exit 0; } # resolve diff -my $diff = word_diff $infile1, $infile2, { STYLE => 'HTMLTwoLines' }; +my $diff = word_diff $text1, $text2, { STYLE => 'HTMLTwoLines' }; # apply markup to each file div of resolved diff my $d = "<div class=\"file\">"; @@ -87,6 +91,6 @@ my $page = html( CHUNK( $diffchunk[1] ), ), ); -write_file( $outfile, $page ); +write_file( $outfile, { binmode => ':utf8' }, $page ); 1; |