Skip to content

fix: preserve Unicode characters in Pretty JSON formatting#7731

Open
sfmskywalker with Copilot wants to merge 2 commits into
release/3.8.0from
copilot/pretty-json-view-unicode-characters
Open

fix: preserve Unicode characters in Pretty JSON formatting#7731
sfmskywalker with Copilot wants to merge 2 commits into
release/3.8.0from
copilot/pretty-json-view-unicode-characters

Conversation

Copilot AI commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Purpose

Pretty JSON rendering was escaping non-ASCII characters (e.g., ÆØÅ) into \uXXXX, while raw JSON showed readable text. This change aligns formatter output with expected human-readable Unicode rendering.


Scope

Select one primary concern:

  • Bug fix (behavior change)
  • Refactor (no behavior change)
  • Documentation update
  • Formatting / code cleanup
  • Dependency / build update
  • New feature

If this PR includes multiple unrelated concerns, please split it before requesting review.


Description

Problem

Pretty JSON output used default serialization behavior in JsonFormatter.ToStringAsync, causing non-ASCII characters to be emitted as escaped Unicode sequences, reducing readability in JSON viewer pretty mode.

Solution

  • Formatter serialization path
    • JsonFormatter now serializes using its configured _options instead of default JsonSerializer.Serialize(value).
  • Unicode encoder configuration
    • Added JavaScriptEncoder.Create(UnicodeRanges.All) to formatter options to preserve readable Unicode text.
  • Regression coverage
    • Added JsonFormatterTests.ToStringAsync_DoesNotEscapeUnicodeCharacters to assert ÆØÅ remains unescaped.
_options = new JsonSerializerOptions
{
    Encoder = JavaScriptEncoder.Create(UnicodeRanges.All)
};

var json = JsonSerializer.Serialize(value, _options);

Verification

Steps:

  1. Open JSON viewer content containing non-ASCII characters (e.g., {"name":"ÆØÅ"}).
  2. Switch to Pretty view.
  3. Confirm characters render as ÆØÅ (not \u00C6\u00D8\u00C5).

Expected outcome:
Pretty and Raw views both display readable Unicode characters for non-ASCII content.


Screenshots / Recordings (if applicable)


Commit Convention

We recommend using conventional commit prefixes:

  • fix: – Bug fixes (behavior change)
  • feat: – New features
  • refactor: – Code changes without behavior change
  • docs: – Documentation updates
  • chore: – Maintenance, tooling, or dependency updates
  • test: – Test additions or modifications

Clear commit messages make reviews easier and history more meaningful.


Checklist

  • The PR is focused on a single concern
  • Commit messages follow the recommended convention
  • Tests added or updated (if applicable)
  • Documentation updated (if applicable)
  • No unrelated cleanup included
  • All tests pass

Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix display of Unicode characters in Pretty JSON view fix: preserve Unicode characters in Pretty JSON formatting Jun 17, 2026
Copilot AI requested a review from sfmskywalker June 17, 2026 18:19
@sfmskywalker
sfmskywalker marked this pull request as ready for review June 21, 2026 17:29
@greptile-apps

greptile-apps Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

PR author is not in the allowed authors list.

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.

Pretty JSON view escapes Unicode characters

2 participants