I need to convert a hex value stored in a wchar_t c-style string to an int. the atoi function has the parameter radix for this, but the wtoi only takes a wchar_t. Is there a function(usable for c++, much c functions are deprecated in c++) or another way to achieve this?;
Asked
Active
Viewed 564 times
0
-
Besides the C-function [`std::wcstol`](https://en.cppreference.com/w/cpp/string/wide/wcstol) there's also [`std::stoi`](https://en.cppreference.com/w/cpp/string/basic_string/stol). Both of these should be easy to find out about with a little searching. – Some programmer dude Oct 12 '19 at 14:02
1 Answers
1
std::stoi
is overloaded on both std::string
and std::wstring
and takes an optional base parameter. You can construct a std::wstring
form a wchar_t
c-style string.

Paul Evans
- 27,315
- 3
- 37
- 54