Skip to content

Can I use UTF-8 as default encoding on MS-Windows? ​

Recent versions of MS-Windows (Windows 10 since build 1803, and Windows 11 or later versions) allow to use UTF-8 (a.k.a. “codepage 65001”) as the default system codepage. As of this writing, this is still an experimental feature, even in Windows 11, and is disabled by default. On Windows 11 you can enable it as follows:

  1. Open Settings.
  2. Select “Time & Language”, then “Language & region”.
  3. Click on “Administrative language settings”.
  4. On the dialog that pops up click “Change system locale...”
  5. In the “Region Settings” dialog that pops up, check the check-box labeled “Beta: Use Unicode UTF-8 for worldwide language support”, then confirm by clicking “OK” to both dialogs.

Emacs supports this feature starting from version 30.2, but only when running on the versions of Windows that provide this feature, and only if the Emacs executable was linked against the ‘UCRT’ library as the Windows C runtime, not against the older ‘MSVCRT’. This is because the C functions that deal with non-ASCII characters, as implemented by ‘MSVCRT’, don’t support UTF-8 as the multibyte encoding of non-ASCII characters. (Which runtime to link against is determined by the person who built your Emacs binary. Note that using Emacs linked against ‘UCRT’ needs all of the libraries loaded by Emacs dynamically, such as GnuTLS, image libraries like ‘rsvg’, Tree-sitter, and all the others, to be also linked against ‘UCRT’, otherwise subtle problems could happen when dealing with non-ASCII characters and strings.)

If you have an Emacs linked against ‘UCRT’, and you turned on the UTF-8 support in Windows as described above, you can customize Emacs to use UTF-8 as your default encoding, e.g., by adding

emacs-lisp
 (prefer-coding-system 'utf-8)

to your init file, or by using the ‘UTF-8’ language environment (see Language Environments in The GNU Emacs Manual) in your Emacs sessions.

Please be aware that, since this feature of Windows is still in beta, there could be some subtle issues with it. So we do not yet recommend to turn this on, unless you feel adventurous.