Mood:

Well quite simple, but still quite frequently asked in forums... :) There are two macros that does this for us. They are as follows. Note: You must include atlconv.h A2W - ANSI to UNICODE W2A - UNICODE to ANSI Before using these two macros you have to use this macro too... USES_CONVERSION Here is a code snippet for you... ;) //#include <atlconv.h> //An example for converting from ANSI to UNICODE //use this first USES_CONVERSION; //An ANSI string LPSTR lpsz_ANSI_String = "An ANSI String"; //ANSI string being converted to a UNICODE string LPWSTR lpUnicodeStr = A2W( lpsz_ANSI_String ) //Another example for converting from UNICODE to ANSI //Use this first USES_CONVERSION //A UNICODE string LPWSTR lp_UNICODE_STR = L"A Unicode String"; //UNICODE string being converted to a ANSI string LPSTR lpsz_ANSI_STR = W2A( lp_UNICODE_STR ); So that's it we are done with it. Ah wait don't leave here's a homework for you... Rip apart CW2A and CA2W :))
Posted by Nibu babu thomas
at 3:49 PM
Updated: Saturday, 20 May 2006 3:53 PM