gin/render
Md Mushfiqur Rahim 3ddf111092 fix: encode non-BMP characters as UTF-16 surrogate pairs in AsciiJSON
The AsciiJSON Render method used fmt.Appendf(buf, "\u%04x", r) for all
non-ASCII runes. For non-BMP characters (code points > 0xFFFF, e.g. emoji),
this produced invalid JSON with raw 5+ hex digit sequences like \u1f389.

Fix: use utf16.Encode([]rune{r}) to convert non-BMP runes into UTF-16
surrogate pairs, producing valid JSON like \ud83c\udf89.

Fixes #4688

Signed-off-by: Md Mushfiqur Rahim <20mahin2020@gmail.com>
2026-06-13 09:38:33 +00:00
..