When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
1 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
cout << "▘"
output = "?"
#include <iostream>
#include <Windows.h>
#include <string>
using namespace std;
int main() {
system("CLS");
cout << "▘";
return 0;
}
I think you meant to output the string not to read the character.
Also the code should be inside
```cpp
code in new line
```
int main(){ return 0; }
For unicode instead of using std::cout, you have to use std::wcout and for unicode input you should use std::wcin instead of std::cin.
And for strings std::wstring instead of std::string, and wchat_t[] instead of char[]
#include <iostream>
#include <Windows.h>
#include <string>
int main() {
system("CLS");
std::wcout << L"▘";
return 0;
}
Make sure that the font that your program is using has this code point, otherwise you might get the ? again.
The L before "" means that the text should be encoded in wchar_t rather than char.
I'd use the regular std::cout, but switch it to UTF-8 mode.
#include <iostream>
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX 1
#include <windows.h>
#endif
int main()
{
#ifdef _WIN32
SetConsoleCP(CP_UTF8);
SetConsoleOutputCP(CP_UTF8);
#endif
std::cout << "▘\n";
}
Make sure your source code is saved as UTF-8 as well
std::print() and std::println() are also probably worth mentioning since they handle utf-8 nicely compared to std::cout.
;compile clang_trunk -std=c++23
#include <cstdint>
#include <print>
#include <string>
static std::string to_utf8_str(uint32_t c) {
char seq[8]{};
int32_t n{ 0 };
if (c < 0x80)
n = 1;
else if (c < 0x800)
n = 2;
else if (c < 0x10000)
n = 3;
else if (c < 0x200000)
n = 4;
else if (c < 0x4000000)
n = 5;
else if (c <= 0x7fffffff)
n = 6;
seq[n] = '\0';
switch (n) {
case 6:
seq[5] = 0x80 | (c & 0x3f);
c = c >> 6;
c |= 0x4000000;
[[fallthrough]];
case 5:
seq[4] = 0x80 | (c & 0x3f);
c = c >> 6;
c |= 0x200000;
[[fallthrough]];
case 4:
seq[3] = 0x80 | (c & 0x3f);
c = c >> 6;
c |= 0x10000;
[[fallthrough]];
case 3:
seq[2] = 0x80 | (c & 0x3f);
c = c >> 6;
c |= 0x800;
[[fallthrough]];
case 2:
seq[1] = 0x80 | (c & 0x3f);
c = c >> 6;
c |= 0xc0;
[[fallthrough]];
case 1:
seq[0] = static_cast<char>(c);
}
return { seq, seq + n };
}
int main() {
for (uint32_t i = 1024; i < 1279; ++i) {
std::string asdf = to_utf8_str(i);
std::print("{}", asdf);
}
}
ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓєѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁ҂҃҄҅҈҉ҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӏӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹ
@proven quail
Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.
!close
Thank you and let us know if you have any more questions!
This thread is now set to auto-hide after an hour of inactivity
!solved