-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy path65472.cpp
49 lines (44 loc) · 1.65 KB
/
65472.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//@YuukiHenri
//May man eventually become the measure of all things.
#include <iostream>
#include <codecvt>
#ifdef _WIN32
#include <Windows.h>
#endif
using std::cout;
using std::endl;
using std::string;
using std::u32string;
string u32_to_bytes(auto s);
int main(int argc, const char *argv[]) {
#ifdef _WIN32
SetConsoleOutputCP(65001);
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED);
cout << u32_to_bytes(U"██████") << endl;
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_BLUE);
cout << u32_to_bytes(U"█████") << endl;
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED);
cout << u32_to_bytes(U"████") << endl;
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_BLUE);
cout << u32_to_bytes(U"███████") << endl;
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED);
cout << u32_to_bytes(U"██") << endl;
SetConsoleTextAttribute(handle, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
#else
#define NC "\x1b[0m"
#define R "\x1b[0;31m"
#define B "\x1b[0;34m"
cout << R << u32_to_bytes(U"██████") << endl;
cout << B << u32_to_bytes(U"█████") << endl;
cout << R << u32_to_bytes(U"████") << endl;
cout << B << u32_to_bytes(U"███████") << endl;
cout << R << u32_to_bytes(U"██") << endl;
cout << NC;
#endif
return 0;
}
string u32_to_bytes(auto s) {
std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> converter;
return converter.to_bytes(s);
}