#Printing unicodes in cmd.exe

31 messages · Page 1 of 1 (latest)

terse lynx
#

Hey, so I'm having some issues with printing unicode characters
I want to print
"▁ ▂ ▃ ▄ ▅ ▆ ▇ █" these.
The output is ? ? ? ? ? ? ? ?

#include <windows.h>
#include <stdio.h>

int main(int argc, char *argv[]) {
    SetConsoleOutputCP(CP_UTF8);

    wprintf(L"%lc\t%lc\t%lc\t%lc\n", 0x03B1, 0x03B2, 0x03B3, 0x03B4);
    return 0;
}
scarlet shuttleBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

terse lynx
#

setlocale(LC_CTYPE, "");
and wchars also don't work

valid hemlock
#
#include <fcntl.h>
#include <io.h>
#include <stdio.h>
#include <windows.h>

int main(void)
{
        _setmode(1, _O_WTEXT);
        wprintf(L"\x2585 \x2586 \x2587\n");
}
#

something like this, ig

#

well, STDOUT_FILENO should work instead of 1

#

although I'm not sure Windows libraries have that constant

terse lynx
#

Yea that works

valid hemlock
#

_fileno(stdin) I think

terse lynx
#

oh god thank you bro

scarlet shuttleBOT
#

Thank you and let us know if you have any more questions!

This thread is now set to auto-hide after an hour of inactivity

icy hollow
icy hollow
#

Use printf normally.

terse lynx
#

I just

#

Said

#

Nothing works except what this guy said

icy hollow
#

It works here.

terse lynx
#

I want it in cmd.exe not in bere

icy hollow
#

?

terse lynx
#

tgat didn't work for .r

#

me*

#

try the chars I want to print

icy hollow
terse lynx
#

Ok.. that's odd because it didn't work for m3

sleek isle
#

you need to use chcp to get unicode in cmd eh?

#

ah or use the win32 call to do it in-program i suppose

#

you did see the SetConsoleCP() there, right?

valid hemlock
#

you just need to choose whether you want to work with wchars and utf16 or with utf8 and set things accordingly