Skip to content

CodePageUtil: map Windows code pages 932 and 950 to Microsoft charsets - #1518

Merged
pjfanning merged 2 commits into
apache:trunkfrom
nikhil1511:codepage-932-950
Nov 2, 2026
Merged

pjfanning merged 2 commits into
apache:trunkfrom
nikhil1511:codepage-932-950

Conversation

@nikhil1511

@nikhil1511 nikhil1511 commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Updates CodePageUtil.codepageToEncoding so Windows code pages 932 (CP_SJIS) and 950 map to Microsoft's charset tables rather than strict JIS Shift_JIS and IBM x-IBM950:

  • 932 (CP_SJIS): returns "MS932" (javaLangFormat == true) and "windows-31j" (javaLangFormat == false), preserving NEC special characters (①, ㈱) and IBM extensions (髙). CP_MAC_JAPAN (10001) continues to return "SJIS".
  • 950: returns "MS950" (javaLangFormat == true) and "x-windows-950" (javaLangFormat == false) instead of falling through to "cp950" (an alias for x-IBM950 in OpenJDK), matching CP_GBK (936) and CP_MS949 (949).

If convenient, please also consider backporting this fix to the 5.5.x branch.

Testing

  • Verified existing HPSF property reading and writing (TestShiftJIS.doc and TestChineseProperties.doc).

Closes #1514

Disclosure: Developed with assistance from Google Gemini (Generated-by: Google Gemini); reviewed and verified by the author.

Map CP_SJIS (932) to MS932 / windows-31j instead of strict JIS X 0208
Shift_JIS, and map code page 950 to MS950 / x-windows-950 instead of
falling through to "cp950" (which resolves to IBM's x-IBM950 in Java).
CP_MAC_JAPAN (10001) continues to return "SJIS".

Closes apache#1514

Generated-by: Google Gemini
@pjfanning

pjfanning commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

There are no plans for 5.x releases. I'll review this later and merge to trunk if it's a valid approach. Only critical issues would be considered for a back port.

CodePageUtil.codepageToEncoding(950, true) now returns MS950
(Microsoft's Big5 variant) instead of cp950, so the encoding guessed
for chinese-traditional.msg changes accordingly.

@pjfanning pjfanning left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@pjfanning
pjfanning merged commit e754561 into apache:trunk Nov 2, 2026
4 checks passed
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.

CodePageUtil: code pages 932 and 950 resolve to strict JIS Shift_JIS and IBM x-IBM950 instead of Windows-31J and x-windows-950

2 participants