google / filament

Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WebGL2
https://google.github.io/filament/
Apache License 2.0
17.35k stars 1.84k forks source link

Treatment of escaped vs unescaped Unicode character in JSON strings #7846

Open scurest opened 1 month ago

scurest commented 1 month ago

Describe the bug Escaped unicode characters in glTF are treated differently than unescaped ones.

"name": "\u4f60\u597d"         // escaped
"name": "你好"                 // unescaped

See also 2.7 JSON Encoding in the glTF spec: "Non-ASCII characters stored in glTF JSON MAY be escaped. [...] [Two examples differing only in string escaping] represent the same glTF JSON data."

To Reproduce

  1. Open EscapedUnicodeTest.glb.zip with bin/gltf_viewer from the latest release. Note that the node name is shown as \u4f60\u597d.
  2. Do the same with UnicodeTest.glb.zip. Note that the node name is shown as ??. (Presumably this is because the font doesn't have the correct glyphs. This issue is just about the discrepancy though, not the font.)

Expected behavior No difference between these persists beyond the JSON loading phase.

Screenshots With "\u4f60\u597d"

With "你好"

Desktop (please complete the following information):

Additional context The Blender glTF exporter currently writes the escaped form (it's the default for Python's builtin JSON library). A user presumably noticed the difference in Filament and reported a bug to Blender: https://projects.blender.org/blender/blender/issues/121692