Convert a C program to Unicode
Posted on 2006-04-21
I need some directional help on how to convert a C program to unicode. The program has no UI and pulls information from a PC to write to a text file, as a sort of discovery process. However when it runs on Japanese or Russian machines it doesnt work properly. The spec roughly is...
- All incoming strings (from registry, windows api, wmi, WNet functions etc) should be able to cope with unicode
- The program should still work without installation on clean build Windows 95 or later
- No reference to MFC or other DLLs that might not be there is allowed
The existing program is about 4000 lines long, with most output strings set to char*, and uses CRT funcs like strncat, memset, malloc, free, memcpy, strtok, strlen, etc
1. What string types should I use instead of char / char * ? I would like to standardise on a single string type throughout the program if poss
2. Should I continue to use malloc and just multiple all the string lengths by 2 ?
3. What string functions should I use in place of those CRT functions.
At the moment I think some of the incoming data to the program (e.g. from WMI) is probably already in unicode or BSTR form. Some functions seem to declare incoming data as BSTR, some as WCHAR_T. It has intermediate calls to wcstombs, SysAllocString and the like
I would also like to know if
is actually a unicode string or some other kind of string.
As you can probably tell my biggest problem is only basic knowledge of C programming with unicode so the more help and direction you can give me the better...
And it would be nice if I can wrap up the string conversion into functions away from the core logic so any suggestions there would be appreciated. ..
thanks in advance