fix: std.manifestYamlDoc passes through Unicode characters natively#1017
Open
He-Pin wants to merge 2 commits into
Open
fix: std.manifestYamlDoc passes through Unicode characters natively#1017He-Pin wants to merge 2 commits into
He-Pin wants to merge 2 commits into
Conversation
Motivation:
YamlRenderer hardcoded escapeUnicode = true, causing all non-ASCII
characters to be escaped as \uXXXX sequences. Both C++ jsonnet and
jrsonnet pass through Unicode characters directly in YAML output.
Modification:
- YamlRenderer.scala: Change escapeUnicode from true to false in
both the key visitor (line 26) and value visitor (line 68).
Result:
std.manifestYamlDoc("世界") now outputs "世界" instead of
"\u4e16\u754c", matching C++ jsonnet and jrsonnet.
Cross-implementation comparison:
| Expression | C++ jsonnet | sjsonnet (before) | sjsonnet (after) |
|--------------------------------------|-------------|------------------------|-------------------|
| std.manifestYamlDoc("世界") | "世界" | "\u4e16\u754c" ❌ | "世界" ✅ |
| std.manifestYamlDoc("café") | "café" | "caf\u00e9" ❌ | "café" ✅ |
| std.manifestYamlDoc("🌍") | "🌍" | "\ud83c\udf0d" ❌ | "🌍" ✅ |
| std.manifestYamlDoc({name: "世界"}) | name: 世界 | name: \u4e16\u754c ❌ | name: 世界 ✅ |
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.manifestYamlDoc passes through Unicode characters natively
Motivation
YamlRendererhardcodedescapeUnicode = true, causing all non-ASCII characters to be escaped as\uXXXXsequences in YAML output. C++ jsonnet, go-jsonnet, and jrsonnet all pass through Unicode characters directly.Modification
YamlRenderer.scala: ChangedescapeUnicodefromtruetofalsein both key visitor (line 26) and value visitor (line 68).yaml_unicode_native_output.jsonnet(golden generated from C++ jsonnet)Result
YAML output contains native Unicode characters, matching all reference implementations.
manifestYamlDoc("世界")"世界""世界""世界""\u4e16\u754c"❌"世界"✅manifestYamlDoc("café")"café""café""café""caf\u00e9"❌"café"✅manifestYamlDoc("🌍")"🌍""🌍""🌍""\ud83c\udf0d"❌"🌍"✅