From da2853d0ecf10a87de2f084b99abbc7c854ad72c Mon Sep 17 00:00:00 2001 From: ZhenYi <434836402@qq.com> Date: Tue, 28 Apr 2026 09:42:52 +0800 Subject: [PATCH] fix(blob): use TextDecoder for proper UTF-8 decoding - atob() returns Latin-1 binary string, not UTF-8 - Chinese characters decoded incorrectly causing mojibake - Use TextDecoder("utf-8") with Uint8Array for correct handling --- src/components/repository/file-browser.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/repository/file-browser.tsx b/src/components/repository/file-browser.tsx index 8ba6ce8..fac4de1 100644 --- a/src/components/repository/file-browser.tsx +++ b/src/components/repository/file-browser.tsx @@ -115,9 +115,11 @@ export const FileBrowser = ({ branch, initialPath = "" }: FileBrowserProps) => { }); const data = resp.data?.data; if (!data) return null; - // Content is base64 encoded + // Content is base64 encoded, use TextDecoder for proper UTF-8 handling try { - return atob(data.content); + const binary = atob(data.content); + const bytes = Uint8Array.from(binary, c => c.charCodeAt(0)); + return new TextDecoder("utf-8", { fatal: false }).decode(bytes); } catch { return data.content; }