Domanda

I print messages with diacritics in my console application. I tried to set multiple encoding commonly used for my language (CZECH) but non of them is giving me the desired result. I tried UTF-8, Windows(CP1250), ISO 8859-2...

Is there a way how to force console to use some specific encoding?

Or at least where can I find which encoding does my console use?

Thanks in advance.

EDIT: Using Windows 7 - basic command line console ( cmd.exe )

È stato utile?

Soluzione

To display the current codepage in cmd.exe:

chcp

To change the current codepage, e.g., to CP-1250:

chcp 1250

Altri suggerimenti

By default, the Windows console uses the OEM encoding. There are three encodings for APIs in Windows OEM, ANSI and Unicode. CMD.exe when normally executed uses OEM.

UTF8 seems to be possible, but needs

  1. starting the console with "cmd /u" (create a shortcut)
  2. setting the codepage to chcp 65001
  3. choosing a unicode capable font (e.g. Consolas 20) in the settings of the shortcut
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top