【发布时间】:2018-11-06 10:21:52
【问题描述】:
我需要写一个简单的比较。
if (user entered "Д" first)
{
//do something
}
问题是我需要比较 Unicode 字符(在本例中是俄语字母“Д”)。
我设法通过以下方式做到这一点:
std::string option;
getline(std::cin, option);
if (option.compare(0, 1, u8"Д"))
{
//do something
}
如何在不使用 std::string 和 compare 的情况下使用 char 执行此操作?虽然如果您为std::string 提供更好的解决方案,我会很高兴。
【问题讨论】: