Encode JIS X 0212 characters with the standard 3-byte form - #63
Open
gaoflow wants to merge 1 commit into
Open
Conversation
The EUC-JP and ISO-2022-JP encoders consulted UTF8_TO_JIS_TABLE before UTF8_TO_JISX0212_TABLE. 280 JIS X 0212 code points are also duplicated in UTF8_TO_JIS_TABLE at rows unassigned by JIS X 0208, so they were emitted as a 2-byte code in those rows rather than the JIS X 0212 form, producing output that standard EUC-JP and ISO-2022-JP decoders reject. Fall through to the JIS X 0212 form (EUC-JP SS3 0x8F / ISO-2022-JP ESC $ ( D) whenever a code point is present in both tables.
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 EUC-JP and ISO-2022-JP encoders emit 280 JIS X 0212 characters in a non-standard 2-byte form that no standard decoder accepts. These code points are duplicated into
UTF8_TO_JIS_TABLEat rows unassigned by JIS X 0208, and that table is checked beforeUTF8_TO_JISX0212_TABLE, so the existing 3-byte path (encoding-convert.js:718) is never reached.For example U+4E28 encodes to
[0xF9,0xAD], which Python'seuc_jprejects, whereas the library's own decoder and the changelog's "Supports JIS X 0212:1990" expect[0x8F,0xB0,0xA9]:When a code point is present in both tables it now uses the JIS X 0212 form. The 280 affected characters occupy JIS X 0208 rows 13 and 89-92, which are all unassigned, so no genuine JIS X 0208 character is rerouted and Shift_JIS output is unchanged. Verified against Python
euc_jp/iso2022_jp_2: all 280 now round-trip;npm testpasses (178).