Skip to content

Fix UTF-8 encoding corruption in R scripts reading JSON from stdin#4509

Draft
xzhou82 with Copilot wants to merge 3 commits into
masterfrom
copilot/debug-survival-series-labels
Draft

Fix UTF-8 encoding corruption in R scripts reading JSON from stdin#4509
xzhou82 with Copilot wants to merge 3 commits into
masterfrom
copilot/debug-survival-series-labels

Conversation

Copilot AI commented May 13, 2026

Copy link
Copy Markdown
Contributor

Description

UTF-8 characters in series labels (e.g., '≥30.78') were corrupted to '��30.78' in R script outputs. R was defaulting to system encoding rather than UTF-8 when reading stdin.

Changes

Fixed four R scripts that read JSON data containing potentially non-ASCII labels:

  • R/src/survival.R - survival analysis
  • R/src/cuminc.R - cumulative incidence analysis
  • R/src/regression.R - regression analysis
  • R/src/density.R - density calculations

Each changed from:

con <- file("stdin", "r")
json <- readLines(con)

To:

con <- file("stdin", "r", encoding="UTF-8")
json <- readLines(con)

The readLines() call inherits encoding from the connection, so no additional parameter needed.

Checklist

Check each task that has been performed or verified to be not applicable.

  • Tests: Added and/or passed unit and integration tests, or N/A
  • Todos: Commented or documented, or N/A
  • Notable Changes: updated release.txt, prefixed a commit message with "fix:" or "feat:", added to an internal tracking document, or N/A
  • Rust: Checked to see whether Rust needs to be re-compiled because of this PR, or N/A

@xzhou82

xzhou82 commented May 13, 2026

Copy link
Copy Markdown
Collaborator

this fix doesn't work
test link still shows
image

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