Skip to content

Add a mode to the renderer to substitute *anything* outside of the ASCII space#402

Open
estebank wants to merge 1 commit intorust-lang:mainfrom
estebank:force-ascii
Open

Add a mode to the renderer to substitute *anything* outside of the ASCII space#402
estebank wants to merge 1 commit intorust-lang:mainfrom
estebank:force-ascii

Conversation

@estebank
Copy link
Copy Markdown

When encountering some non-printable Unicode characters, we replace them with printable Unicode representations of them. This replacement still relies on Unicode support on the user's terminal. In order to enable use on... less modern systems, added a force_ascii mode to the renderer that replaces anything outside of the ASCII with a replacement string:

error: oops
 --> <current file>:2:8
  |
2 | Second oops <SOH> line
  |        ^^^^ oops

instead of the current

error: oops
 --> <current file>:2:8
  |
2 | Second oops ␁ line
  |        ^^^^ oops

This change unearthed a latent bug where the rendered snippet gets out of sync with the Annotation lo and hi char position, making highlighting spans that had characters replaced with a different number of bytes to be improperly highlighted, as noted in the svg test.

…CII space

When encountering some non-printable Unicode characters, we replace them with printable representations of them. This replacement still relies on Unicode support on the user's terminal. In order to enable use on... less modern systems, added a `force_ascii` mode to the renderer that replaces anything outside of the ASCII with a replacement string:

```
error: oops
 --> <current file>:2:8
  |
2 | Second oops <SOH> line
  |        ^^^^ oops
```

This change unearthed a latent bug where the rendered snippet gets out of sync with the `Annotation` lo and hi char position, making highlighting spans that had characters replaced with a different number of bytes to be improperly highlighted.
@epage
Copy link
Copy Markdown
Contributor

epage commented Apr 10, 2026

Generally, I find it helpful to discuss things first in issues so conversations don't get fragmented and can be found where people expected them. I just noticed we don't have the contrib guide specifically requesting that.

This replacement still relies on Unicode support on the user's terminal. In order to enable use on... less modern systems

Could you provide more context on the end-user concerns that this is addressing? What types of terminals are we talking about? Why is this coming up now?

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