S
S
sddvxd2018-04-25 16:39:50
C++ / C#
sddvxd, 2018-04-25 16:39:50

Why doesn't the compiler skip Unicode?

Hello! For undertakings in WINAPI, it was necessary to study Unicode, its types and code writing:

#include <Windows.h>
#include <iostream>

using namespace std;
int main(void) {
  CHAR * c = "ANSI STRING";
  WCHAR * wc = L"Строка юникода";

  cout << wc << endl;
  cin.get();
}

When I try to compile the example, I get this:
main.cpp:7:15: error: converting to execution character set: Illegal byte sequence
  WCHAR * wc = L"Строка юникода";

Please explain why

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Satisfied IT, 2018-04-25
@sddvxd

In the project settings on the GENERAL tab there is a CHARACTER SET parameter that indicates in what encoding the program will be compiled:
What do you have there?

M
maaGames, 2018-04-25
@maaGames

char, wchar_t instead of WCHAR.
std::wcout to output unicode characters.
And it may be necessary to change the locale of the console, but it's better to google it, I'll write it wrong from memory.

V
Vitaly, 2018-04-25
@vt4a2h

If I were you, I would use the standard wchar_t and output the value to wcout.
Well, it might be worth tweaking the compilation flags for WCHAR This flag seems to be /Zc:wchar_t.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question