Encoding plugin¶
An Encoding menu for re-reading a file in a different character encoding, or converting it to one. The editor works in UTF-8 internally; this plugin decides how a file's bytes map to and from that.
Your file keeps its encoding¶
OctoEdit detects a file's encoding when it opens it and writes the same
encoding back on every save. A UTF-8 file with a byte-order mark keeps its
BOM, a UTF-16 file stays UTF-16, and a file in the system's ANSI code page is
not silently promoted to UTF-8 the first time you press Ctrl+S.
The encoding belongs to the document, not to this plugin: the menu below shows it and changes it, and the editor core is what does the writing. That is also why a conversion gets the same treatment as any other save — the write is atomic, backup-on-save applies, and the file watcher knows the change was yours.
A project .editorconfig with a charset still wins: that is a decision you
wrote down for the whole project, and it overrides what a single file's bytes
happened to say. After such a save the document reports that charset as its
encoding, so the menu and the status bar name what is actually on disk.
Two kinds of command¶
The distinction matters — one changes interpretation, the other changes what the file will be saved as:
| Family | Menu | What it does |
|---|---|---|
| Interpret as | Encoding ▸ <encoding> and Encoding ▸ Character sets ▸ <set> |
Re-reads the file's bytes from disk and decodes them with the chosen encoding, replacing the buffer, and records that encoding on the document. Use it when a file opened as mojibake. The file on disk is untouched until you save. |
| Convert to | Encoding ▸ Convert to <encoding> |
Marks the document as "to be saved in this encoding" and marks it modified. No bytes are written yet — save the document to apply the conversion, or close it without saving to abandon it. |
The encoding the active document currently uses is ticked in the menu, in
the top-level list for the Unicode/ANSI entries and inside
Encoding ▸ Character sets for the legacy ones. The mark follows the active
tab, so switching documents tells you at a glance what each one is.
The status bar names the same encoding in its own segment (UTF-8,
UTF-8-BOM, ANSI, Windows-1250, …) and follows the active document too —
so you can see what a file is without opening the menu.
Available encodings¶
- Unicode: UTF-8, UTF-8-BOM, UTF-16 LE BOM, UTF-16 BE BOM.
- ANSI — the system's local single-byte code page.
- Character sets submenu — the legacy sets grouped by language: Arabic, Baltic, Celtic, Central European, Chinese, Cyrillic, Eastern European, Greek, Hebrew, Japanese, Korean, North European, Thai, Turkish, Vietnamese and Western European.
Convert to offers the five Unicode/ANSI primaries. A legacy code page is reachable through Interpret as, and a document read that way is written back in that same code page.
Fixing a garbled file
If a file opens as gibberish, try Interpret as with the encoding you expect (e.g. a legacy character set). When it reads correctly, Convert to UTF-8 and save, to store it in a modern, portable encoding.