【问题标题】:wstring.find_last_not_of() treats everything after international char as space?wstring.find_last_not_of() 将国际字符之后的所有内容视为空格?
【发布时间】:2012-06-10 19:00:06
【问题描述】:
#include <iostream>
#include <windows.h>
using namespace std;

int main() {
  wstring my_str(L"El Niño     ");
  cout << my_str.find_last_not_of(L' ');
}

此代码返回 6 但不应返回 7 ?

【问题讨论】:

    标签: c++ unicode wstring


    【解决方案1】:

    索引从零开始。最后一个非空格字符的索引在索引 6:

    L"El Niño     "
            ^
      0123456
    

    【讨论】:

    • 起来,对不起。好的,我忘记了。
    猜你喜欢
    • 2014-09-13
    • 2012-03-08
    • 2015-08-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多