Skip to content

Globe: EBCDIC SO/SI Bytes (DBCS) Break Java String Offsets #3985

Closed

Description

@squid-protocol

Part of GitGalaxy Tours the Globe 🌍

The Defect

When dealing with Japanese/Kanji (Double-Byte Character Sets or DBCS), IBM EBCDIC mixes single-byte English and double-byte Kanji by injecting hidden control bytes: 0x0E (Shift-Out) and 0x0F (Shift-In).

In CobolRecords.text(), we decode bytes into Java Strings using new String(rec, offset, length, charset). When the Charset decoder encounters SO/SI bytes, it consumes them. This means a 20-byte COBOL string on the mainframe might decode into a Java String of only 15 characters.

The Impact

COBOL strictly defines variables by byte-length, and modernization developers frequently use myString.substring() or myString.length() assuming it matches the COBOL definition. Because the Java string "shrunk" during decoding, any padding, substring, or fixed-width export logic in the generated Java will throw an IndexOutOfBoundsException or corrupt the adjacent data stream.

Required Action

Implement a CobolString wrapper or a paddedEbcdicString() helper in CobolRecords that retains the logical byte-width of the string (e.g., by padding with spaces if SO/SI bytes were consumed), ensuring Java string manipulations mirror the mainframe's memory geometry.

Activity

  1. added
    data-integrity
    legacy-modernization
    on Sep 28, 2026
  2. added a commit that references this issue on Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    data-integritylegacy-modernizationpriority: medium

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions