You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Files viewer rejects GBK / GB18030 text files ('This file is not UTF-8 text') #43192
Open main.c in the Files Viewer (either from the workspace file tree or by clicking a file link in a message).
Expected behavior
The Files Viewer should decode and display readable Chinese text (for example by falling back to gb18030 when strict UTF-8 decoding fails, consistent with #42735 for the Diff panel and #42827 for RTF previews), while keeping valid UTF-8 files (including files truncated at FILE_TEXT_PREVIEW_MAX_BYTES) decoded as UTF-8.
Actual behavior
The Files Viewer fails to render the file and shows:
This file is not UTF-8 text. Open it in another app to view its contents.
In packages/shared/src/filePreview.ts (decodeFilePreviewText, lines 171–184):
constdecoder=newTextDecoder("utf-8",{fatal: true});try{return{text: decoder.decode(bounded,{stream: truncated||bytes.length>bounded.length}),truncated: truncated||bytes.length>bounded.length,};}catch{thrownewError("This file is not UTF-8 text. Open it in another app to view its contents.");}
Because decodeFilePreviewText only tries strict utf-8 and throws immediately on error, non-UTF-8 CJK text files (such as GBK/GB18030 .c, .h, .txt, .csv files, and text entries inside zip previews) cannot be opened in the Files Viewer even though the Diff panel (#42735) and RTF preview (#42827) now handle GBK/GB18030.
Impact
Major degradation or frequent failure
Version or commit
0.1.13-nightly.20261125.5258 (also verified on main: packages/shared/src/filePreview.ts)
Environment
Windows 11, T3 Code Desktop 0.1.13-nightly.20261125.5258
I'm on it. decodeFilePreviewText only attempts strict UTF-8, so it throws before any fallback; I'll try a GB18030 decode when strict UTF-8 fails (same approach as #42735), while keeping UTF-8 precedence and the binary/NUL check intact.
Activity
2SinceJuly commentedon Nov 26, 2026
I'm on it.
decodeFilePreviewTextonly attempts strict UTF-8, so it throws before any fallback; I'll try a GB18030 decode when strict UTF-8 fails (same approach as #42735), while keeping UTF-8 precedence and the binary/NUL check intact.