Repository navigation
Japanese in every document and data format - #148
Merged
Merged
Conversation
Legacy encodings read everywhere: text, Markdown, and HTML in Shift_JIS, EUC-JP, or ISO-2022-JP (declared or detected), CSV/TSV and XML decoded as they stream, and Word's RTF in code page 932. The PDF writer embeds CID-keyed CFF fonts (Hiragino, Noto Sans CJK), prefers Japanese fonts for Japanese, and breaks Japanese lines with kinsoku.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The rest of the Japanese work, after 1.0.1's PDF reading.
charset/encodingis followed, otherwise the encoding is detected. CSV/TSV (Excel saves Japanese CSVs as Shift_JIS) and XML are decoded as they stream. Detection takes bytes for Japanese only when most two-byte characters fall in the common JIS rows, so Latin-1 and Windows-1252 files are still refused with an error rather than turned into kanji.\ansicpg932,\fcharset128) and half-width katakana read in full; they read as U+FFFD before.src/io/font/cff.rs). Rendered with poppler, Quartz and MuPDF for both Hiragino and Noto Sans CJK. Japanese text now prefers a Japanese font over Arial Unicode.Tested with a matrix of 20 Japanese document sources (pandoc, textutil, LibreOffice, Word-style RTF, and Shift_JIS/EUC-JP files) and 5 data sources, each converted to every format and read back: 100% of the text throughout.
New tests:
tests/japanese_input.rs: eight legacy-encoded inputs fromtests/fixtures/japanese-input/make.py.tests/to_pdf.rs: CFF embedding with a 9.6 KB Noto Sans CJK subset, OFL-licensed.