关于#中文乱码#的问题,如何解决?

中文乱码

运行结果是
鎴慳i
提示是
[stl.cpp 2023-01-19 07:45:55.009]
,,stl.cpp:5: warning: ignoring #pragma execution_character_set [-Wunknown-pragmas]
#pragma execution_character_set("utf-8")

这什么弄,who can help me

```c++
#include
#include
#include
#include  
using namespace std;
//string字符串拼接
void test(){
    string s1= "我";
    s1 += "ai";
    cout<int main(){
    test();
}

很多时候是在其他的环境或者是记事本写的代码产生的,可以参考这一篇文章
https://blog.csdn.net/qq_55359819/article/details/119535095


#include <iostream>
using namespace std;
#include <cstring>
#include <atlstr.h>
#include <fstream>
#include <string>
string UTF8ToGB(const char* str)
 
{
    string result;
    WCHAR *strSrc;
    LPSTR szRes;
    //获得临时变量的大小
    int i = MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0);
    strSrc = new WCHAR[i + 1];
    MultiByteToWideChar(CP_UTF8, 0, str, -1, strSrc, i);
    //获得临时变量的大小
    i = WideCharToMultiByte(CP_ACP, 0, strSrc, -1, NULL, 0, NULL, NULL);
    szRes = new CHAR[i + 1];
    WideCharToMultiByte(CP_ACP, 0, strSrc, -1, szRes, i, NULL, NULL);
    result = szRes;
    delete[]strSrc;
    delete[]szRes;
    return result;
}
 
int main()
{
    string a = "我";
    string b=UTF8ToGB(a.c_str());
    b+="ai";
    cout << b << endl;
}