I'm trying to make a code where I make Lenny jump, but lenny's face this: ( ͡° ͜ʖ ͡°)
When compile & run the code (g++ -o Lenny main.cpp), I get the output "( ͡° �~\�~V ͡°)". Is there a way I can get it to display ( ͡° ͜ʖ ͡°)?
I'm trying to make a code where I make Lenny jump, but lenny's face this: ( ͡° ͜ʖ ͡°)
When compile & run the code (g++ -o Lenny main.cpp), I get the output "( ͡° �~\�~V ͡°)". Is there a way I can get it to display ( ͡° ͜ʖ ͡°)?
Linux has good Unicode support, you don't need any special libraries if all you're doing is output:
#include <iostream>
int main()
{
std::cout << "( ͡° ͜ʖ ͡°)\n";
}
online demo: http://ideone.com/UUS6Il
Or, you could not rely on Linux's built-in UTF-8 and be explicit about it:
#include <iostream>
#include <locale>
int main()
{
std::locale::global(std::locale("en_US.utf8"));
std::wcout.imbue(std::locale());
std::wcout << L"( ͡° ͜ʖ ͡°)\n";
}
online demo: http://ideone.com/EhTfB9
EDIT: Based on your code in the comment, your question is actually about the ncurses library I/O, not about C++. To get your program work as expected,
setlocale(LC_ALL, "en_US.utf8");
near the beginning of your main()
(and add #include <clocale>
accordingly)-lncursesw
as opposed to -lncurses
if that's what you're using.