【问题标题】:Chars and foreign letters c++ throws Debug Assertion Failed字符和外文字母 c++ throws Debug Assertion Failed
【发布时间】:2020-09-29 14:20:10
【问题描述】:

当我尝试在 Visual Studio 中编译和运行此代码时,它会引发 Debug Assertion Failed 错误。

        char c = 'æ';

我相信这与编码和编译器有关,但我的文件以 uft-8 格式保存。我还尝试将 /utf-8 添加到属性页面上的附加选项中,指定为here,但它并没有解决问题。你知道如何解决这个问题吗?

【问题讨论】:

  • 声明是什么引发了错误?你没用isalpha()之类的函数吗?
  • 使用 utf8 并不意味着 utf8 字符或字形可以放入字符中。
  • 阅读Character types
  • æ 是两个字节 \xc3\xa6。它不适合一个char

标签: c++ visual-studio encoding utf-8


【解决方案1】:

我建议你使用stringchar 不适合输出æ

string c="æ";
for (int i = 0; i < c.length(); i++)
{
    cout << c[i];
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-28
    • 2021-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-09
    • 1970-01-01
    相关资源
    最近更新 更多