My high level goal is to convert any string (can include non-ascii characters) into a vector of integers by converting each character to integer.
I already have a python code snippet for this purpose:
bytes = list(text.encode())
Now I want to have a C++ equivalent. I tried something like
int main() {
char const* bytes = inputText.c_str();
long bytesLen = strlen(bytes);
auto vec = std::vector<long>(bytes, bytes + bytesLen);
for (auto number : vec) {
cout << number << endl;
}
return 0;
}
For an input string like "testΔ", the python code outputs [116, 101, 115, 116, 206, 148].
However C++ code outputs [116, 101, 115, 116, -50, -108].
How should I change the C++ code to make them consistent?