From 588f0a846be95ed9c2effdeb34aefc1ee4e7b01e Mon Sep 17 00:00:00 2001 From: Admin Date: Fri, 17 Jul 2026 12:54:32 +0000 Subject: [PATCH] fix: another UTF-8 string index bug in debug output --- internal/captcha/handler.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/captcha/handler.go b/internal/captcha/handler.go index eb7461b..46bf0e1 100644 --- a/internal/captcha/handler.go +++ b/internal/captcha/handler.go @@ -327,7 +327,11 @@ func (h *Handler) Math(imageBase64 string) (result string, err error) { maxIdx = c } } - fmt.Printf("DEBUG: Position 0 argmax = %d (char: %s)\n", maxIdx, string("0123456789+-*/÷×=?."[maxIdx-1])) + // 【注意】这里用 string 索引访问多字节字符可能有问题,仅用于调试 + debugChars := []string{"", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "-", "*", "/", "÷", "×", "=", "?"} + if maxIdx >= 0 && maxIdx < len(debugChars) { + fmt.Printf("DEBUG: Position 0 argmax = %d (char: %s)\n", maxIdx, debugChars[maxIdx]) + } if len(output) == 0 { return "", fmt.Errorf("模型输出为空")