New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open rnc files using UTF-8 encoding #14
Comments
Thanks for the feedback! Your proposal makes sense to me. I see you've already prepared a fix, do you want to submit that as a PR? I can merge it and publish a new release if that helps. |
I haven't been able to test the patch yet. I have asked @yurivict who ran into the issue to verify whether it works. |
From the RELAX NG Compact Syntax reference, it seems that rnc files loaded from the filesystem should indeed always be opened as UTF-8 of UTF-16, depending on the BOM:
|
Passing |
I suspect we could use |
I'm not sure how that would work. It doesn't seem to be able to detect the encoding of the file. The RNC spec suggests that files are either UTF-8 of UTF-16 encoded. The latter only when a BOM is present. So we could open the file in binary mode and read the first two bytes to determine the encoding to use (UTF-8, UTF-16 BE or UTF-16 LE). |
If a UTF-16 BOM is present, use UTF-16 encoding. Otherwise, assume UTF-8 encoding. See the "Character encoding" section of the RELAX NG Compact Syntax specification. Fixes djc#14
|
rnc2rng currently uses the platform's default encoding when reading rnc files. This causes platform-dependent issues: brechtm/citeproc-py#81. I think it would be safe to assume that rnc files will be UTF-8 encoded, so it would make sense to always load rnc files using UTF-8.
The text was updated successfully, but these errors were encountered: