Hi I was trying to output unicode string to a console with iostreams and failed.
I found this: Using unicode font in c++ console app and this snippet work
chcp to find which codepage works for you. In my case it was chcp 28591 for Western Europe.REG ADD HKCU\Console /v CodePage /t REG_DWORD /d 28591I had a similar problem, with Java. It is just cosmetic, since it involves log lines sent to the console; but it is still annoying.
The output from our Java application is supposed to be in UTF-8 and it displays correctly in eclipse's console. But in windows console, it just shows the ASCII box-drawing characters: Inicializaci├│n and art├¡culos instead of Inicialización and artículos.
I stumbled upon a related question and mixed some of the answers to get to the solution that worked for me. The solution is changing the codepage used by the console and using a font that supports UNICODE (like consolas or lucida console). The font you can select in the system menu of the Windows cosole:
Win + R then type cmd and hit the Return key.Win key and type cmd followed by the return key.Alt + Space key combinationConsolas or Lucida consoleOKRegarding the codepage, for a one-off case, you can get it done with the command chcp and then you have to investigate which codepage is correct for your set of characters. Several answers suggested UTF-8 codepage, which is 65001, but that codepage didn't work for my Spanish characters.
Another answer suggested a batch script to interactively selecting the codepage you wanted from a list. There I found the codepage for ISO-8859-1 I needed: 28591. So you could execute
chcp 28591
before each execution of your application. You might check which code page is right for you in the Code Page Identifiers MSDN page.
Yet another answer indicated how to persist the selected codepage as the default for your windows console. It involves changing the registry, so consider yourself warned that you might brick your machine by using this solution.
REG ADD HKCU\Console /v CodePage /t REG_DWORD /d 28591
This creates the CodePage value with the 28591 data inside the HKCU\Console registry key. And that did work for me.
Please note that HKCU ("HKEY_CURRENT_USER") is only for the current user. If you want to change it for all users in that computer, you'll need to use the regedit utility and find/create the corresponding Console key (probably you'll have to create a Console key inside HKEY_USERS\.DEFAULT)