Smart Encoding Converter
Smart Encoding Converter helps VS Code users detect likely legacy text encodings and convert files to a configured target encoding.
It is designed for old projects that often mix UTF-8 with GBK, GB18030, Big5, Shift_JIS, or UTF-16 files.
Features
- Prompt when an opened file does not match the configured target encoding.
- Detect the likely encoding of the current file.
- Convert the current file to the configured target encoding.
- Scan and convert matching files in the current workspace.
- Skip common binary and generated folders.
Commands
Smart Encoding: Detect Current File Encoding
Smart Encoding: Convert Current File
Smart Encoding: Convert Workspace
Settings
{
"smartEncodingConverter.autoConvertOnOpen": true,
"smartEncodingConverter.promptOnOpen": true,
"smartEncodingConverter.promptBeforeConvert": true,
"smartEncodingConverter.targetEncoding": "utf8",
"smartEncodingConverter.include": [
"**/*.{c,h,cpp,hpp,txt,md,ini,cfg,log,java,js,ts,py,json,xml,html,css}"
],
"smartEncodingConverter.exclude": [
"**/.git/**",
"**/node_modules/**",
"**/dist/**",
"**/build/**",
"**/out/**",
"**/.vscode/**"
],
"smartEncodingConverter.minimumConfidence": 0.65
}
Supported target encodings:
utf8
utf8bom
gb18030
gbk
big5
shift_jis
utf16le
Notes
Encoding detection is probabilistic. The extension asks before single-file conversion by default. Before running workspace conversion on an existing project, commit or back up your files.
When smartEncodingConverter.autoConvertOnOpen is enabled, high-confidence mismatched files are converted as soon as they are opened. Disable it if you prefer manual command-based conversion.
Encoding to gb18030, gbk, big5, or shift_jis requires the iconv-lite dependency. Run npm install in the extension folder before using those target encodings during development.
Packaging
Install Node.js and run:
npm install
npm run package
This creates a .vsix file that can be installed from VS Code's Extensions view.
Publishing
- Replace
publisher in package.json with your Marketplace publisher ID.
- Create or verify your publisher in the VS Code Marketplace publisher management page.
- Run:
npm install -g @vscode/vsce
vsce login <publisher-id>
vsce publish