24,854
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <locale>
using namespace std;
int main( void )
{
locale loc( "chs" );
wcout.imbue( loc );
std::wcout << L"中国" << endl;
return 0;
}
[/quote]
这个程序在vscode上为什么无法运行[/quote]
不知道,请把你的代码和报的错贴出来~[/quote]
刚才那个是GBK,如果是UTF8则是这样的:
D:\TEST\VScode\cpp>cd "d:\TEST\VScode\cpp\" && g++ chs.cpp -o chs && "d:\TEST\VScode\cpp\"chs
terminate called after throwing an instance of 'std::runtime_error'
what(): locale::facet::_S_create_c_locale name not valid
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.[/quote]
谢谢你,问题解决了,不知大神可否帮忙设计一个人民币大写的程序[/quote]
我是感觉5楼的代码应该可行,就是不知道如何实现#include <iostream>
#include <locale>
using namespace std;
int main( void )
{
locale loc( "chs" );
wcout.imbue( loc );
std::wcout << L"中国" << endl;
return 0;
}
[/quote]
这个程序在vscode上为什么无法运行[/quote]
不知道,请把你的代码和报的错贴出来~[/quote]
刚才那个是GBK,如果是UTF8则是这样的:
D:\TEST\VScode\cpp>cd "d:\TEST\VScode\cpp\" && g++ chs.cpp -o chs && "d:\TEST\VScode\cpp\"chs
terminate called after throwing an instance of 'std::runtime_error'
what(): locale::facet::_S_create_c_locale name not valid
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.[/quote]
谢谢你,问题解决了,不知大神可否帮忙设计一个人民币大写的程序#include <iostream>
#include <locale>
using namespace std;
int main( void )
{
locale loc( "chs" );
wcout.imbue( loc );
std::wcout << L"中国" << endl;
return 0;
}
[/quote]
这个程序在vscode上为什么无法运行[/quote]
不知道,请把你的代码和报的错贴出来~[/quote]
刚才那个是GBK,如果是UTF8则是这样的:
D:\TEST\VScode\cpp>cd "d:\TEST\VScode\cpp\" && g++ chs.cpp -o chs && "d:\TEST\VScode\cpp\"chs
terminate called after throwing an instance of 'std::runtime_error'
what(): locale::facet::_S_create_c_locale name not valid
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.#include <iostream>
#include <locale>
using namespace std;
int main( void )
{
locale loc( "chs" );
wcout.imbue( loc );
std::wcout << L"中国" << endl;
return 0;
}
[/quote]
这个程序在vscode上为什么无法运行[/quote]
不知道,请把你的代码和报的错贴出来~[/quote]
vscode中报错如下:
> Executing task: C:\Mingw-w64\mingw64\bin\g++.exe -g d:\TEST\VScode\cpp\chs.cpp -o d:\TEST\VScode\cpp/chs.exe <
d:\TEST\VScode\cpp\chs.cpp: In function 'int main()':
d:\TEST\VScode\cpp\chs.cpp:8:15: error: converting to execution character set: Illegal byte sequence
std::wcout << L"中国" << endl;
^~~~~~~
The terminal process terminated with exit code: 1
Terminal will be reused by tasks, press any key to close it.
#include <iostream>
#include <locale>
using namespace std;
int main( void )
{
locale loc( "chs" );
wcout.imbue( loc );
std::wcout << L"中国" << endl;
return 0;
}
[/quote]#include <iostream>
#include <locale>
using namespace std;
int main( void )
{
locale loc( "chs" );
wcout.imbue( loc );
std::wcout << L"中国" << endl;
return 0;
}
[/quote]#include <iostream>
#include <locale>
using namespace std;
int main( void )
{
locale loc( "chs" );
wcout.imbue( loc );
std::wcout << L"中国" << endl;
return 0;
}
[/quote]
这个程序在vscode上为什么无法运行#include <iostream>
#include <locale>
using namespace std;
int main( void )
{
locale loc( "chs" );
wcout.imbue( loc );
std::wcout << L"中国" << endl;
return 0;
}