首页 > 解决方案 > c++如何在没有 ICU(gcc/cl 编译器)之类的东西的情况下在没有 wchar 的情况下在 c++ 中使用 utf-8 和/或 utf-32?

问题描述

我尝试了很多东西,但它们似乎不起作用。

#include <iostream>
#include <locale>

using namespace std;

int main() {
    setlocale(LC_ALL, "en-US.utf8");
    std::string uni = u8"ユチエフー8";
    std::cout << uni;

    std::cin.get();
    return 0;

}

请注意,我希望 utf-8/utf-32 不仅在这种情况下工作,而且在大多数情况下不使用宽字符之类的东西。

标签: c++unicodeutf-8c++20utf-32

解决方案


推荐阅读