std::wcstol, std::wcstoll
Min standard notice:
Header: <cwchar>
Interprets an integer value in a wide string pointed to by str.
# Declarations
long wcstol ( const wchar_t* str, wchar_t** str_end, int base );
long long wcstoll( const wchar_t* str, wchar_t** str_end, int base );
(since C++11)
# Parameters
str: pointer to the null-terminated wide string to be interpretedstr_end: pointer to a pointer to wide characterbase: base of the interpreted integer value
# Return value
Integer value corresponding to the contents of str on success. If the converted value falls out of range of corresponding return type, range error occurs and LONG_MAX, LONG_MIN, LLONG_MAX or LLONG_MIN is returned. If no conversion can be performed, 0 is returned.
# Example
#include <cwchar>
#include <errno.h>
#include <iostream>
#include <string>
int main()
{
const wchar_t* p = L"10 200000000000000000000000000000 30 -40";
wchar_t* end;
std::wcout << "Parsing L'" << p << "':\n";
for (long i = std::wcstol(p, &end, 10); p != end; i = std::wcstol(p, &end, 10))
{
std::wcout << '\'' << std::wstring(p, end-p) << "' -> ";
p = end;
if (errno == ERANGE)
{
std::wcout << "range error, got ";
errno = 0;
}
std::wcout << i << '\n';
}
}