Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sjsonnet/src/sjsonnet/TomlRenderer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class TomlRenderer(
if (s == null) {
visitNull(index)
} else {
BaseRenderer.escape(out, s, unicode = true)
BaseRenderer.escape(out, s, unicode = false)
flush
}
}
Expand Down Expand Up @@ -161,7 +161,7 @@ object TomlRenderer {

def writeEscapedKey(out: StringBuilderWriter, key: CharSequence): Unit = {
if (isBareKey(key)) out.write(key.toString)
else BaseRenderer.escape(out, key, unicode = true)
else BaseRenderer.escape(out, key, unicode = false)
}

def escapeKey(key: String): String = if (isBareKey(key)) key
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Regression test: TOML output must pass through Unicode natively.
// Golden verified against cpp-jsonnet 0.21.0, go-jsonnet 0.22.0, jrsonnet 0.5.0-pre99.
std.assertEqual(
std.manifestToml({name: "世界", drink: "café", emoji: "🌍"}),
"drink = \"café\"\nemoji = \"🌍\"\nname = \"世界\""
) &&
std.assertEqual(
std.manifestToml({section: {key: "日本語"}}),
"\n\n[section]\n key = \"日本語\""
) &&
true
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
true
2 changes: 1 addition & 1 deletion sjsonnet/test/src/sjsonnet/UnicodeHandlingTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ object UnicodeHandlingTests extends TestSuite {

// TOML manifest:
eval(s"std.manifestTomlEx($testObject, ' ')") ==>
ujson.Str("a = 1\nz = 2\n\"\\uffff\" = 3\n\"\\ud800\\udc00\" = 4")
ujson.Str("a = 1\nz = 2\n\"\uFFFF\" = 3\n\"\uD800\uDC00\" = 4")
}

test("findSubstr") {
Expand Down
Loading