Skip to content

Commit

Permalink
Resolves incompatibility of listings package with utf8 encoding. Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ftilmann committed Jul 16, 2024
1 parent a789b50 commit 3ecfc17
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions latexdiff
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
# - File added via --preamble option is no longer assumed to be ASCII, but read either with encoding as defined by --encoding option or using the encoding of the LOCALE (fixes issue #285 )
# - multicolumn argument is now treated as text
# - when tikz-dependency package is used, \& is no longer a safe command as it has special meaning inside dependency environment. The fix is a little of a hack as really it should only be considered unsafe within dependency environment (fixes (mostly) issue #303 )
# - listings package had trouble with non-ASCII chars. The encoding is now set (thanks to github user anka-213 for finding this). Fixes #304
#
# Version 1.3.3:
# New features:
Expand Down Expand Up @@ -924,7 +925,7 @@ if (defined($labels[1])) {
$encoding=guess_encoding($newfile) unless defined($encoding);

$encoding = "utf8" if $encoding =~ m/^utf8/i ;
###print STDERR "Encoding $encoding\n" if $verbose;
print STDERR "Encoding $encoding\n" if $verbose;
if (lc($encoding) eq "utf8" ) {
binmode(STDOUT, ":utf8");
binmode(STDERR, ":utf8");
Expand Down Expand Up @@ -1173,7 +1174,7 @@ if ( defined($packages{"listings"}) or `kpsewhich listings.sty` ne "" ) {
}
my @listingDIFcode=();
my $replaced;
# note that in case user supplies preamblefile the type might not reflect well the
# note that in case user supplies preamblefile the type might not reflect well the actual markup style
@listingDIFcode=extrapream("-nofail","DIFCODE_" . $type) unless defined($preamblefile);
if (!(@listingDIFcode)) {
# if listingDIFcode is empty try to guess a suitable one from the preamble
Expand All @@ -1187,6 +1188,10 @@ if ( defined($packages{"listings"}) or `kpsewhich listings.sty` ne "" ) {
@listingDIFcode=extrapream("DIFCODE_BOLD");
}
}
# add configuration so that listings work with utf-8
push @listingpreamble, '\lstset{extendedchars=\true,inputencoding='.$encoding."}\n";


# now splice it in
$replaced=0;
###print STDERR "DEBUG: listingDIFcode: ",join("\n",@listingDIFcode),"|||\n" if $debug;
Expand Down

0 comments on commit 3ecfc17

Please sign in to comment.