CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
/*
Want a much shorter version, without all the mode saving stuff?
See the comments for a much cleaner implementation
by Nautash Ahmad. It's like 2 lines of setup
and then it just works!
*/
/////////////////////////////////////////////////////
// This block enables UTF16 for SoloLearn's c++
/////////////////////////////////////////////////////
// fflush is ADVISED. utf16 BOM \xfeff is REQUIRED.
// constructor/destructor pattern is a feature of GCC
#include <io.h> // _setmode
#include <fcntl.h> // _O_U16TEXT
#include <cstdio> // _fileno
int _oldMode; // this + destructor could be skipped here
void _startup(void) __attribute__ ((constructor));
void _shutdown(void) __attribute__ ((destructor));
void _startup(void){
fflush(stdout);
_oldMode = _setmode(_fileno(stdout),_O_U16TEXT);
wprintf(L"\xfeff");
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run