Skip to content

binmode not needed if we always output bytes - #938

Merged
brucemiller merged 2 commits into
brucemiller:masterfrom
dginev:latexmlc-stdout-enconding
Feb 3, 2018
Merged

binmode not needed if we always output bytes#938
brucemiller merged 2 commits into
brucemiller:masterfrom
dginev:latexmlc-stdout-enconding

Conversation

@dginev

@dginev dginev commented Feb 3, 2018

Copy link
Copy Markdown
Collaborator

Simple enough (now that we have a proper understanding), all result prints expect bytes now, i.e. the result to be printed has already been utf-8 encoded.

@dginev

dginev commented Feb 3, 2018

Copy link
Copy Markdown
Collaborator Author

Fixes #926 for latexmlc

@dginev

dginev commented Feb 3, 2018

Copy link
Copy Markdown
Collaborator Author

well, almost. A certain path through latexmlc still has wide characters as a serialization never gets utf-8 encoded. Which is why I was wondering if we shouldn't put the encode call already in serialize_aux in Document, since I think this is the only serializer that does not explicitly do an encoding to bytes.

The current master branch shifts that responsibility to the executables, notably latexml, which means I need to be extra careful in latexmlc to not skip a case. Luckily some of the tests for the daemon runs test the logs!

@dginev

dginev commented Feb 3, 2018

Copy link
Copy Markdown
Collaborator Author

Added a commit that should handle things with the current approach.

@brucemiller

Copy link
Copy Markdown
Owner

The thing that got us in trouble was the inconsistency: one rare case being already encoded when most other stuff was characters. I'd prefer to keep things as consistent and localized as possible. So, I'm less inclined to change Core::Document's approach. But you're right that latexmlc has to deal with a variety of objects and we need a way to know (or use polymorphism) whether each object is encoded or not.

@dginev

dginev commented Feb 3, 2018

Copy link
Copy Markdown
Collaborator Author

Wouldn't a convention that any toString method returns an encoded string be more consistent?

@dginev

dginev commented Feb 3, 2018

Copy link
Copy Markdown
Collaborator Author

The other type of object that latexmlc can return are archives, and that is just binary data, so it follows the result is just bytes convention

@brucemiller
brucemiller merged commit 47597b4 into brucemiller:master Feb 3, 2018
@brucemiller

Copy link
Copy Markdown
Owner

Oh, I just merged, but probably would like to request a comment to the effect of method is always bytes (similar to what I added in latexml/math, perhaps?)

@dginev dginev mentioned this pull request Feb 3, 2018
@dginev
dginev deleted the latexmlc-stdout-enconding branch February 25, 2018 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants