Skip to content

Instantly share code, notes, and snippets.

@shuujii
Created February 9, 2014 10:25
Show Gist options
  • Select an option

  • Save shuujii/8897221 to your computer and use it in GitHub Desktop.

Select an option

Save shuujii/8897221 to your computer and use it in GitHub Desktop.
diff --git a/bin/diff-highlight b/bin/diff-highlight
index c4404d4..b568c9f 100755
--- a/bin/diff-highlight
+++ b/bin/diff-highlight
@@ -2,6 +2,7 @@
use warnings FATAL => 'all';
use strict;
+use Encode qw(decode_utf8 encode_utf8);
# Highlight by reversing foreground and background. You could do
# other things like bold or underline if you prefer.
@@ -73,11 +74,12 @@ sub show_hunk {
my @queue;
for (my $i = 0; $i < @$a; $i++) {
- my ($rm, $add) = highlight_pair($a->[$i], $b->[$i]);
- print $rm;
+ my ($rm, $add) =
+ highlight_pair(decode_utf8($a->[$i]), decode_utf8($b->[$i]));
+ print encode_utf8($rm);
push @queue, $add;
}
- print @queue;
+ print encode_utf8($_) for @queue;
}
sub highlight_pair {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment