Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Printing out Korean in console C++

Tags:

c++

I am having trouble with printing out korean. I have tried various methods with no avail. I have tried

1.

    cout << "한글" << endl;

2.

    wcout << "한글" << endl;

3.

    wprintf(L"한글\n");

4.

    setlocale(LC_ALL, "korean");
    wprintf("한글");

and more. But all of those prints "한글". I am using MinGW compiler, and my OS is windows 7.

P.S Strangely Java prints out Korean fine,

    String kor = "한글";
    System.out.println(kor);

works.

like image 463
user3879095 Avatar asked Jul 26 '14 05:07

user3879095


1 Answers

Set the console codepage to utf-8 before printing the text

::SetConsoleOutputCP(65001)
like image 128
dvasanth Avatar answered Nov 09 '22 12:11

dvasanth