Unicode Support
 
With Total Commander 7.5 (packer plugin interface 2.20), Unicode support has been added to all plugin types. In principle, you need to implement the same functions as for ANSI, with two differences: The function name is changed from FunctionName to FunctionNameW, and Ansi strings are changed to wide char names.
 
Total Commander will call the Unicode functions on all NT-based systems (Windows NT, 2000, XP) if they are present. If not, or on Windows 9x/ME, Total Commander will call the Ansi functions.
 
The following functions of the packer plugin interface support Unicode:
 
OpenArchiveW
ReadHeaderExW
ProcessFileW
SetChangeVolProcW
SetProcessDataProcW
PackFilesW
DeleteFilesW
StartMemPackW
CanYouHandleThisFileW
 
The following functions do not exist in a Unicode form and must be implemented as Ansi:
 
ReadHeader - use ReadHeaderEx
CloseArchive
GetPackerCaps
ConfigurePacker
PackToMem
DoneMemPack
PackSetDefaultParams
ReadHeaderEx
 
What's the easiest way to support Unicode in an existing plugin?
1. Get my sample plugin fsplugin (file system plugins section) even if you write a different type of plugin!
2. Add the files cunicode.h and cunicode.cpp to your project. They contain various functions to make Unicode support easier.
3. Convert your existing functions to Unicode and rename them to FunctionNameW. For all file functions like CreateFile, do not call their Unicode counterpart CreateFileW directly. Instead, call the functions from cunicode.cpp like CreateFileT. These functions automatically call the right Unicode or Ansi function, and even support file name lengths >259 characters!
4. For each converted function like FunctionNameW, recreate a function FunctionName which you call this way:
 
int __stdcall FunctionName(char* SomeString1,char* SomeString2)
{
WCHAR SomeString1W[wdirtypemax],SomeString2W[wdirtypemax];
return FunctionNameW(awfilenamecopy(SomeString1W,SomeString1),awfilenamecopy(SomeString2W,SomeString2));
}
 
The Macro awfilenamecopy will convert the Ansi string SomeString1 to Unicode and store it inSomeString1W. This variable must not be a pointer, because awfilenamecopy uses "countof" to get the target length.