Skip to content

Render readable Unicode in formatted JSON response body - #745

Merged
haga-rak merged 1 commit into
mainfrom
fix/740-json-unicode-escapes
Jul 21, 2026
Merged

haga-rak merged 1 commit into
mainfrom
fix/740-json-unicode-escapes

Conversation

@haga-rak

@haga-rak haga-rak commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Fixes the escaping part of #740.

The JSON formatter escaped every non ASCII character as \uXXXX because Utf8JsonWriter uses JavaScriptEncoder.Default. Switch to UnsafeRelaxedJsonEscaping and restore supplementary characters, which the encoder cannot allow list, through a surrogate pair aware pass. Control characters, quotes and backslashes remain escaped and the output stays valid JSON.

Covered by new offline unit tests in ResponseBodyJsonFormattingTests.

The JSON formatter escaped every non ASCII character as \uXXXX because
Utf8JsonWriter uses JavaScriptEncoder.Default. Switch to
UnsafeRelaxedJsonEscaping and restore supplementary characters, which
the encoder cannot allow list, through a surrogate pair aware pass.
Control characters, quotes and backslashes remain escaped and the
output stays valid JSON.
@haga-rak
haga-rak merged commit adf7b61 into main Jul 21, 2026
2 checks passed
@haga-rak haga-rak added the bug Something isn't working label Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant