Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Encoding GuardNew to Visual Studio Code? Get it now.
Encoding Guard

Encoding Guard

deviousprophet

|
7 installs
| (1) | Free
Protects you from wrong encodings — Automatically detects and applies the correct file encoding on open.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Encoding Guard

Encoding Guard is a VS Code extension that automatically detects and applies the correct file encoding when you open files, so text is never garbled in mixed-encoding projects.

How it works

  1. Pattern matching — Map file patterns to encodings via encoding-guard.patternMap. Patterns are matched by specificity:
    • Exact paths (e.g., data/report.csv) — highest priority, specific file overrides
    • Glob patterns (e.g., src/**/*.xml, **/*.csv) — medium priority, more specific globs win over less specific
    • Extension shorthand (e.g., .csv) — lowest priority, acts as default for all matching extensions
  2. XML declaration — For any file that starts with <?xml ... encoding="..."?>, Encoding Guard reads the declared encoding and silently reopens the file with the correct encoding if VS Code opened it with a different one.

Priority order: patternMap (by specificity) → XML declaration → no action.

Configuration

The easiest way to configure encodings is via the right-click context menu in the Explorer or editor — select Encoding Guard → Set Extension Encoding... or Set File Encoding....

Or edit settings manually:

// Unified pattern map: exact paths, globs, or extension shorthand
// Patterns are matched by specificity: exact paths > globs (more specific first) > extensions
"encoding-guard.patternMap": {
    ".csv":                    "windows1252",     // Default: all .csv files
    "**/*.arxml":              "utf8",            // All .arxml files across directories
    "data/legacy/**/*.txt":    "iso88591",        // Specific subdirectory
    "config/old-report.csv":   "cp1252"           // Override: this specific file
}
  • Settings are resource-scoped: you can set different values per workspace folder.

Files with an <?xml ... encoding="..."?> declaration are handled automatically — no mapping required.

Context menu

Right-click any file in the Explorer or editor to access the Encoding Guard submenu:

Item Action
Set Extension Encoding... Pick an encoding and apply it to all files with this extension (adds .ext to patternMap)
Set File Encoding... Pick an encoding and pin it to this specific file (adds exact path to patternMap)
Open Encoding Guard Settings Open VS Code Settings filtered to Encoding Guard

Issues

Found a bug or want to request a feature? Please open an issue: Issues

Include a short description, steps to reproduce, and sample files when possible.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft