docs: add detailed comment for UTF-8 charset fix
Build and Deploy / build (push) Successful in 2m39s
Build and Deploy / deploy (push) Successful in 1s

This commit is contained in:
2026-07-17 12:45:34 +00:00
parent f7cfc4a888
commit e17549c508
+4 -1
View File
@@ -422,7 +422,10 @@ func decodeMathFromOutput(output []float32) string {
}
// 字符集:索引 1-18 对应字符
// 注意:使用 slice 而不是 string,避免 UTF-8 多字节字符的索引问题
// 【关键修复】使用 string slice 而不是 string,避免 UTF-8 多字节字符的索引错位问题
// Go 的 string 是 UTF-8 编码,for range 迭代时 i 是字节位置而非字符位置
// 模型输出的索引是按字符位置(1-18),直接用 string[idx-1] 访问多字节字符会错位
// 例如:÷ (U+00F7, 2字节) 和 × (U+00D7, 2字节) 会导致后续字符索引跳跃
CHARS := []string{"", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "-", "*", "/", "÷", "×", "=", "?"}
// DEBUG: 打印字符集