ANSI To Unicode

I have a multi-byte project, and I'm not going to change it. However, there are times when I want to make a certain snippet Unicode, such as the SysLink example discussed here, which I have made to work in Unicode numerous times, but of course it ONLY works in Unicode.

Is there a way to define or make just a certain section of my project Unicode so that I can employ as Unicode call, such as the SysLink, for example?

Do I just #define Unicode for that section, or what? Please show me if there is a way. That is, don't explain it, just show me, pleaes.
Are you already using the TEXT() Macro? Because that's the straightest way I know of doing this.
No, my project is multi-byte so the TEXT() macro doesn't apply. I need to switch ONLY this particular function/section to Unicode so that I CAN use the _T("such and such") macro.
Yes. It's easy. Just use the Unicode version of the Win Functions when you want them (the 'W' versions... MessageBoxW, etc) and pass them wide strings.

Whether or not UNICODE is #defined only makes a difference when <Windows.h> is included. #defining it after that is useless.
Yes, that's basically what they told me on the C++ MS forum. What's the difference between wchar_t and tchar? or is there any?
TCHAR is wchar_t if your project uses unicode configuration or plain char otherwise.
wchar_t is different type than char, has 2 bytes on windows platform and holds UTF-16 encoded text.

There is MultiByteToWideChar() API if you want to convert from ansi to unicode.
Last edited on
Thanks, you've all not only answered my question, but it's much simpler than I thought it would be thanks.
Topic archived. No new replies allowed.