Linked Questions

Popular Questions

getting a sub string of a std::wstring

Asked by At

How can I get a substring of a std::wstring which includes some non-ASCII characters?

The following code does not output anything:
(The text is an Arabic word contains 4 characters where each character has two bytes, plus the word "Hello")

#include <iostream>
#include <string>

using namespace std;

int main()
{
    wstring s = L"سلام hello";
    wcout << s.substr(0,3) << endl;
    wcout << s.substr(4,5) << endl;

    return 0;
}

Related Questions