Skip to content

feat: make charset configurable via environment variable - #921

Open
LuisCastellanos-dev wants to merge 3 commits into
opensourcecobol:developfrom
LuisCastellanos-dev:fix/configurable-charset
Open

LuisCastellanos-dev wants to merge 3 commits into
opensourcecobol:developfrom
LuisCastellanos-dev:fix/configurable-charset

Conversation

@LuisCastellanos-dev

Copy link
Copy Markdown

Summary

  • Replace hardcoded Charset.forName("SHIFT-JIS") in AbstractCobolField with System.getenv().getOrDefault("OPENSOURCECOBOL4J_CHARSET", "SHIFT-JIS")
  • Defaults to SHIFT-JIS for backward compatibility
  • Enables non-Japanese deployments to use UTF-8, ISO-8859-1, or other charsets without code changes

Test plan

  • Without env var set: behavior identical to current (SHIFT-JIS)
  • With OPENSOURCECOBOL4J_CHARSET=UTF-8: COBOL programs with Latin/UTF-8 data should process correctly
  • Invalid charset name should throw UnsupportedCharsetException at startup (fast fail)

Fixes #916

Replace hardcoded SHIFT-JIS charset with environment-configurable value.
Defaults to SHIFT-JIS for backward compatibility. Non-Japanese COBOL
programs can now set UTF-8, ISO-8859-1, etc. to avoid silent data
corruption in MOVE, STRING, INSPECT, and file I/O operations.

Fixes opensourcecobol#916
@tsh-hashimoto
tsh-hashimoto self-requested a review October 20, 2026 09:45

This branch has not been deployed

No deployments
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.

Enhancement: Hardcoded SHIFT-JIS charset causes data corruption for non-Japanese COBOL programs

1 participant