Skip to content

Fix members failing to open when SRCDTA contains NUL bytes - #3510

Merged
buzzia2001 merged 1 commit into
codefori:masterfrom
bobcozzi:fix/member-srcdta-nul-bytes
Nov 1, 2026
Merged

buzzia2001 merged 1 commit into
codefori:masterfrom
bobcozzi:fix/member-srcdta-nul-bytes

Conversation

@bobcozzi

@bobcozzi bobcozzi commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Opening certain legacy source members fails with VS Code showing:

The file is not displayed in the text editor because it is either binary or uses an unsupported text encoding.

Cause

Some legacy members carry x'00' bytes in SRCDTA — old tooling wrote NUL-terminated strings into full-length CHAR fields (e.g. RPG III template header lines packed with + to the full record length, ending with x'00'). Or in some cases, early versions of VSCODE included a X'00' in some cases.
The byte converts cleanly through CCSID to U+0000, and a single NUL in the text stream makes VS Code's text model classify the document as binary and refuse to display it.

Verified on a member where HEX(RIGHT(SRCDTA, 4)) = 4E4E4E00 — the NUL is the last byte of the record on the host.

Fix

Apply TRANSLATE(srcdta, ' ', x'00') in the SRCDTA SELECT used by the source-date download path, mapping NUL to blank on the host. Applied to both the CCSID-65535 CAST branch and the plain column branch.

Notes

  • Host tools (SEU, CPYSRCF) are unaffected by these bytes; only the text-editor path cares. A copy source member via CPYSRCF preserves the issue so this fix resolves the issue of openning and cleans up that trailing X'00' when it exists.
  • The legacy CPYTOSTMF download path is unchanged; the SQL open code path covers the source-date-enabled option only.
  • No behavior change for clean members (no NULs present → TRANSLATE is a no-op).

Legacy members can carry x'00' bytes in SRCDTA (old tooling wrote
NUL-terminated strings into full-length CHAR fields). The byte converts
cleanly through CCSID to U+0000, and a single NUL makes VS Code's text
model refuse to display the document ('binary or unsupported encoding').

Translate x'00' to blank in the SRCDTA SELECT on the host, so the
downloaded text is clean before it leaves Db2.

@buzzia2001 buzzia2001 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.

Thank you @bobcozzi

@buzzia2001
buzzia2001 merged commit ce906f1 into codefori:master Nov 1, 2026
1 check 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.

2 participants