reflect: fix (u)int -> string conversions for invalid code points

This commit is contained in:
Damian Gryski
2026-05-26 14:28:08 -07:00
committed by Damian Gryski
parent e111b489ec
commit 364ac2dcb2
3 changed files with 96 additions and 7 deletions
+3 -1
View File
@@ -153,7 +153,9 @@ func stringNext(s string, it *stringIterator) (bool, int, rune) {
}
// Convert a Unicode code point into an array of bytes and its length.
func encodeUTF8(x rune) ([4]byte, uintptr) {
func encodeUTF8(r rune) ([4]byte, uintptr) {
x := uint32(r)
// https://stackoverflow.com/questions/6240055/manually-converting-unicode-codepoints-into-utf-8-and-utf-16
// Note: this code can probably be optimized (in size and speed).
switch {