【发布时间】:2015-03-13 17:01:24
【问题描述】:
我正在使用 SFML 用 c++ 编写游戏,我发现了一种支持法语字符的字体。但是,在程序中,我从文件中读取了所有文本以便能够支持不同的语言,但我不知道如何将没有错误的文本提取为宽字符串。
这是我的代码:
using namespace std;
using namespace sf;
void SettingsW :: initialize()
{
// using normal characters it reads the files correctly
wifstream settTextFile;
settTextFile.open(pageTextSource);
wstring temp;
getline(settTextFile, temp);
pageTitle.setFont(pageFont);
pageTitle.setString(temp);
getline(settTextFile, temp, L' ');
languageTitle.setFont(pageFont);
languageTitle.setString(temp);
//here is the problem
char g=' ';
ios::widen(g);
getline(settTextFile, temp, ' '));
// I want to use get line with this delimiter and when I use the L the error goes away
//but it doesn't display properly: é is displayed as ã
}
【问题讨论】:
标签: c++ char sfml wchar wifstream