Help with porting from multiple bytes to UNICODE in MFC

I have a little tedious 6 months to a year ahead of me. I am working on a program with 1 million lines of code (most of them were written in the early / mid 90s), and it was decided that now it should support UNICODE assembly. I researched and found many best practices:

  • using the _t version of many Microsoft and C ++ methods, such as _stprintf_s () instead of sprintf_s () or _tcsstr () instead of strstr (),
  • wrapping all encoded strings that must be TCHAR *, such as _T ("string") or _T ('c'),
  • replaces most char * with LPTSTR and most const char * with LPCTSTR and char with TCHAR using CA2T () and CT2A () to convert between char * and LPTSTR, if necessary,

I was wondering if anyone wrote a script that is able to automatically make many of these changes, as they can save me a MONTH of work.

+4
source share
1 answer

I think this approach fits your scenario exactly.

Leave all your lines narrow, use sprintf and strstr , as before, to read and write from text files that are always considered UTF-8 without specifications, etc. All you need to change is your communication with the system. Suppose now that the strings are UTF-8, and before calling to MFC or Windows, convert to UTF-16 on the fly.

As a bonus, you get easier portability for non-Windows platforms compared to the approach recommended by Microsoft.

+4
source

All Articles