Refactored code that translates to and from wchar_t into static functions