Interested question correct processing of multi languages
// C ++. How to universally define the number of
// characters per line, regardless of the encoding?
#include <iostream>
#include <string>
using namespace std;
int main()
{
// test line 13 characters length
// but the result get is 19 characters
string test_string = "string_строка";
cout << "String length " << test_string.size() << " characters.\n";
return 0;
}
I think that this is due to the different number of allocated memory for the characters of the Latin alphabet and the Cyrillic.
How to solve this is universal? Or simpy for Cyrillic.
My system Ubuntu 14.04 (Unity). Compiler GCC 4.9.1 20140922 (Red Hat 4.9.1-10), 64 bit.