fix: std.manifestToml passes through Unicode characters natively#1018
Open
He-Pin wants to merge 2 commits into
Open
fix: std.manifestToml passes through Unicode characters natively#1018He-Pin wants to merge 2 commits into
He-Pin wants to merge 2 commits into
Conversation
Motivation:
TomlRenderer hardcoded unicode = true, causing all non-ASCII
characters to be escaped as \uXXXX sequences. C++ jsonnet passes
through Unicode characters directly in TOML output.
Modification:
- TomlRenderer.scala: Change unicode from true to false in both
visitString (line 54) and writeEscapedKey (line 164).
- UnicodeHandlingTests.scala: Update objectFieldOrdering test
expectation to use native Unicode instead of escaped form.
Result:
std.manifestToml({name: "世界"}) now outputs name = "世界"
instead of name = "\u4e16\u754c", matching C++ jsonnet.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: std.manifestToml passes through Unicode characters natively
Motivation
TomlRendererhardcodedunicode = true, causing all non-ASCII characters to be escaped as\uXXXXin TOML output. C++ jsonnet, go-jsonnet, and jrsonnet all pass through Unicode characters directly. Companion to PR #1017.Modification
TomlRenderer.scala: ChangedunicodefromtruetofalseinvisitString(line 54) andwriteEscapedKey(line 164).UnicodeHandlingTests.objectFieldOrderingexpectation.toml_unicode_native_output.jsonnetResult
manifestToml({name: "世界"})name = "世界"name = "世界"name = "世界"name = "\u4e16\u754c"❌name = "世界"✅manifestToml({drink: "café"})drink = "café"drink = "café"drink = "café"drink = "caf\u00e9"❌drink = "café"✅