Skip to content

Instantly share code, notes, and snippets.

@Konfekt
Konfekt / e.bat
Last active November 19, 2021 09:24
open %EDITOR% (or vim or notepad) using UTF-8 codepage in Microsoft Windows cmd shell
@echo off
SETLOCAL ENABLEEXTENSIONS
rem From https://superuser.com/questions/1118106/can-the-utf-8-code-page-identifier-65001-be-different-on-other-computers/1121076#1121076
rem capture output of chcp after colon
for /F "tokens=2 delims=:" %%G in ('chcp') do set "_chcp=%%G"
rem strip trailing dots
IF "%_chcp:~-1%"=="." set "_chcp=%_chcp:~0,-1%"
IF DEFINED EDITOR (