Skip to content

Commit

Permalink
Merge pull request #938 from dginev/latexmlc-stdout-enconding
Browse files Browse the repository at this point in the history
binmode not needed if we always output bytes
  • Loading branch information
brucemiller committed Feb 3, 2018
2 parents f48d643 + 25a5c97 commit 47597b4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 0 additions & 4 deletions bin/latexmlc
Expand Up @@ -160,13 +160,9 @@ if ($result) {
if (!open($output_handle, ">", $opts->get('destination'))) {
print STDERR "Fatal:I/O:forbidden Couldn't open output file " . $opts->get('destination') . ": $!";
exit 1; }
if (!$is_archive) { # If we're not outputing binary data, encode to UTF-8
binmode($output_handle, ":encoding(UTF-8)"); }
print $output_handle $result;
close $output_handle;
} else {
if (!$is_archive) { # If we're not outputing binary data, encode to UTF-8
binmode(STDOUT, ":encoding(UTF-8)"); }
print STDOUT $result, "\n"; } #Output to STDOUT
}

Expand Down
4 changes: 3 additions & 1 deletion lib/LaTeXML.pm
Expand Up @@ -315,14 +315,16 @@ sub convert {
undef $serialized;
if ((defined $result) && ref($result) && (ref($result) =~ /^(:?LaTe)?XML/)) {
if (($$opts{format} =~ /x(ht)?ml/) || ($$opts{format} eq 'jats')) {
$serialized = $result->toString(1); }
$serialized = $result->toString(1);
$serialized = Encode::encode('UTF-8', $serialized) if $serialized; }
elsif ($$opts{format} =~ /^html/) {
if (ref($result) =~ /^LaTeXML::(Post::)?Document$/) { # Special for documents
$serialized = $result->getDocument->toStringHTML; }
else { # Regular for fragments
do {
local $XML::LibXML::setTagCompression = 1;
$serialized = $result->toString(1);
$serialized = Encode::encode('UTF-8', $serialized) if $serialized;
} } }
elsif ($$opts{format} eq 'dom') {
$serialized = $result; } }
Expand Down

0 comments on commit 47597b4

Please sign in to comment.