1 year ago

#223124

test-img

user2338150

More elegant way to wrap temporaries around incompatible function call

I'm working on Unicode translation of some legacy code. I have some global functions that accept LPTSTR. Now some part of the code is strictly ANSI and some are strictly UTF-8. I'm doing something like this:

TCHAR szTemp[_countof(wzInputStr)] = {0};
::_tcsncpy(szTemp, CW2T(wzInputStr), _countof(szTemp));
TransformStr(szTemp);
::wcsncpy(wzInputStr, CT2W(szTemp), _countof(wzInputStr));

If a function accepts multiple parameters then it is getting tiresome. What could be some better approach to handle this? This does look like a familiar problem.

c++

winapi

atl

tchar

0 Answers

Your Answer

Accepted video resources