Encoding KeeperEncoding Keeper is a VS Code extension for projects that contain files with mixed encodings. It remembers the preferred encoding for individual files or folders, restores that encoding when files are opened, and can convert files or folders to another encoding. Encoding Keeper 是一个 VS Code 扩展,用于管理工作区内混合编码文件。它可以记录文件或文件夹的编码、打开时自动恢复编码,并支持一键转码。 Features
Supported Encodings
UsageRecord an EncodingRight-click a file or folder in Explorer, then choose:
Select the encoding to remember. Folder records apply to files inside that folder unless a file has its own exact record. Convert EncodingRight-click a file or folder in Explorer, then choose:
Select the target encoding. File conversion runs immediately. Folder conversion shows a confirmation dialog first, then processes files recursively. When converting an open file, Encoding Keeper closes the editor tab before writing the converted bytes. If the file was active, it is reopened with the target encoding afterward. If the source bytes are valid UTF-8, conversion decodes them as UTF-8 even when the file is currently displayed with the wrong encoding. This avoids saving already-garbled editor text when, for example, a UTF-8 file was opened as GB2312. Record FileEncoding records are stored at:
Example:
Matching order:
Commands
Git Diff for Non-UTF-8 FilesWhen VS Code opens a Git diff, the committed side uses a virtual After recording GB2312/GBK for a file, you can use the normal Source Control diff. No separate Encoding Keeper compare command is required. This is equivalent to manually running VS Code's "Reopen with Encoding" action on the Git side of the diff. Notes and Limitations
RequirementsVS Code 1.100.0 or newer is required. DevelopmentInstall dependencies:
Compile and bundle:
Run tests:
Launch the extension locally by pressing Packaging and PublishingCreate a production bundle and package:
Install the generated package locally:
The package-only workflow is Release NotesSee CHANGELOG.md. |