If you just use const wstring &text you don't have to check for NULL, and also don't need to .c_str() the input.