diff --git a/bin/latexmlc b/bin/latexmlc index 87d22b3b5..91776dabe 100755 --- a/bin/latexmlc +++ b/bin/latexmlc @@ -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 } diff --git a/lib/LaTeXML.pm b/lib/LaTeXML.pm index 7c40bfa43..c94988cf2 100644 --- a/lib/LaTeXML.pm +++ b/lib/LaTeXML.pm @@ -315,7 +315,8 @@ 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; } @@ -323,6 +324,7 @@ sub convert { 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; } }