首先,我只想在控制台中使用波罗的海字符并用它们执行 CMD 命令,但问题是从默认/标准控制台 C++ 应用程序开始的。
\n#include <iostream>\nint main() {\n string output = "\xc4\x81\xc4\x81\xc4\x81\xc4\x8d\xc4\x8d\xc4\x8d\xc4\x93\xc4\x93\xc4\x93\xc4\x93";\n\n cout << output << endl;\n}\nRun Code Online (Sandbox Code Playgroud)\n早些时候,我在堆栈上提出了这个问题 - How to use UTF8characters in DEFAULT C++ Project OR when using mysql Connector for C++ in Visual Studio 2019 (Latin7_general_ci to UTF-8)?
\n我在测试中发现:如果我将 UTF8 字符串转换为 Latin1 字符串,然后 cout 或打印十六进制值,我会在控制台中输出一些特殊字符。例如 -
\n**char s2[256] = "\\xc3\\xa9";** printed is outputted as "\xc4\xb7" THAT MEANS I need to convert strings into correct HEX values when it is needed, and some …Run Code Online (Sandbox Code Playgroud)