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
This commit is contained in:
parent
21d0d1eae6
commit
da2853d0ec
@ -115,9 +115,11 @@ export const FileBrowser = ({ branch, initialPath = "" }: FileBrowserProps) => {
|
|||||||
});
|
});
|
||||||
const data = resp.data?.data;
|
const data = resp.data?.data;
|
||||||
if (!data) return null;
|
if (!data) return null;
|
||||||
// Content is base64 encoded
|
// Content is base64 encoded, use TextDecoder for proper UTF-8 handling
|
||||||
try {
|
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 {
|
} catch {
|
||||||
return data.content;
|
return data.content;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user