This guy's biggest problem is that he doesn't know the standard library very well.
I admit it's ugly, but the code below removes whitespace using only standard C++ calls. There's also an isspace() function from the <locale> header that takes a specific locale, but I'm not sure it's important for whitespace.
std::wstring removeSpaces(std::wstring theStr) {
return std::wstring(theStr.begin(),
std::remove_if(theStr.begin(),
theStr.end(),
std::iswspace));
}
There's also codec conversion in the <locale> header [1]. It's also pretty ugly, but it's easier to understand than his home grown solution, and if nothing else, is already debugged. And to be honest, if you're using C++ you should be used to the code being verbose and ugly.