Before this time, I always believe building the program with Unicode or non Unicode flag only effect the programatic side, and won't effect the system behavior. the problem arose with mixing usage of Multi-byte and Unicode Character Set functionalities under
The Unicode base. such as if the Unicode is the base setting, then any multi-byte function's call may appear unpredictable behavior. Please take a look at the following example:
// We suppose the Unicode is defined, but we still need to support the multi-byte stringvoid log (const char * infmt ,...) {char buffer [256]; // something is done. vsprintf (buffer, infmt, valist); wprintf (multibyte_to_unicode (buffer ));}
The output 'buffer' may not process the right string that you want, and the solution is at first convert all the string into Unicode style, and then use the Unicode function to process the string, such:
// We suppose the Unicode is defined, but we still need to support the multi-byte stringvoid log (const char * infmt ,...) {// we are working under Unicode try turn all the string value into Unicode style wchar_t buffer [256]; // something is done. // and then use the Unicode function to process string vswprintf (buffer, multibyte_to_unicode (infmt), valist); wprintf (buffer );}