Change CodePage in CMD permanently?

In the 1809 build of Windows 10 I’ve managed to permanently solve this by going to the system’s Language settings, selecting Administrative language settings, clicking Change system locale… and checking the Beta: Use Unicode UTF-8 for worldwide language support box and then restarting my pc. This way it applies to all applications, even those ones … Read more

chcp 65001 codepage results in program termination without any error

To use Unicode in the Windows console for Python 2.7 and 3.x (prior to 3.6), install and enable win_unicode_console. This uses the wide-character functions ReadConsoleW and WriteConsoleW, just like other Unicode-aware console programs such as cmd.exe and powershell.exe. For Python 3.6, a new io._WindowsConsoleIO raw I/O class has been added. It reads and writes UTF-8 … Read more

Why isn’t UTF-8 allowed as the “ANSI” code page?

The “ANSI” codepage is basically legacy: Windows 9X era. All modern software should be Unicode (that is, UTF-16) based anyway. Basically, when the Ansi code page stuff was originally designed, UTF-8 wasn’t even invented and so support for multi-byte encodings was rather haphazard (i.e. most Ansi code pages are single byte, with the exception of … Read more

PowerShell script runs when pasted into the PowerShell window, but not when run from shortcut

To clarify: It is perfectly fine to use Unicode (non-ASCII-range) quotation marks such as “ in PowerShell – see the bottom section. However, in order to use such characters in script files, these files must use a Unicode character encoding such as UTF-8 or UTF-16LE (“Unicode”). Your problem was that your script file was saved … Read more

Character-encoding problem with string literal in source code

Note: Remoting and use of Invoke-Command are incidental to your problem. Since the problem occurs with a string literal in your source code (…\01_Klassenbücher\…), the likeliest explanation is that your script file is misinterpreted by PowerShell. In Windows PowerShell, if your script file is de facto UTF-8-encoded but lacks a BOM, the PowerShell engine will … Read more

How do you properly use WideCharToMultiByte

Here’s a couple of functions (based on Brian Bondy’s example) that use WideCharToMultiByte and MultiByteToWideChar to convert between std::wstring and std::string using utf8 to not lose any data. // Convert a wide Unicode string to an UTF8 string std::string utf8_encode(const std::wstring &wstr) { if( wstr.empty() ) return std::string(); int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), … Read more