LPSTR, LPWSTR string conversion

Category: VC/MFC -> Foundation Classes Author: pp999pp Date: 2004-05-22 15:33:13
 
pp999pp
2004-05-22 15:33:13
void   chg1 (LPSTR   lpn)
{

if   (lpn = str)
{
xxooxxooxxoo
}

}
str = " this   is   string ";

////////////////////

void   chg2 (LPWSTR   lpn)
{

if   (lpn = str2)
{
xxooxxooxxoo
}

}
str2 = " this is the string ";

use   char   * str = " this   is   string ";
like error , I determine the value of lpn is " this   is   string ";   predicate inside xx00 or does not perform properly convert
how the above two ah
dupengq
2004-05-22 15:39:38
? > int   str_to_wstr (char *   sou,   wchar *   des)
{
      int   size   =   strlen (  sou  );
      int   i;
      int   j;
      for (  i = 0,   j = 0 ;   i < size;   i ++,   j ++  )
      {
            if (  (signed   char) sou [  i  ]   <   0   & &   (i   <   (size   -   1))  )
            {
                  * (((char *) & des [  j  ] ) +0)   =   sou [  i  ];
                  * (((char *) & des [   j  ]) + 1)   =   sou [  ++ i  ];
           }
            else  
            {
                  * ( ((char *) & des [  j  ]) + 0)   =   0;
                  * (( (char *) & des [  j  ]) + 1)   =   sou [  i  ];
           }
     }
      des [  j  ]   =   0;
      return   j;
}
huaxia20092010
2004-05-22 15:43:34
1.char *   to   wchar *
WCHAR *   ToWChar (char   *   str)  

{  
static   WCHAR   buffer [1024];  

wcsset (buffer, 0);  

MultiByteToWideChar (CP_ACP, 0, str, strlen (str), buffer, 1024);  

return   buffer;  

}
2   wchar *   to   char *
(1) use   WideCharToMultiByte

uchar   wszSomeString [1024];  

char   szANSIString   [MAX_PATH];  

WideCharToMultiByte   (  CP_ACP,   WC_COMPOSITECHECK,   wszSomeString,   -1,   szANSIString,   sizeof (szANSIString),   NULL,   NULL  );  

(2) use   W2A:

USES_CONVERSION;

pTemp = W2A (wszSomeString);  
butterfly_liu
2004-05-22 15:55:42
first, if inside with     ==   instead   =
hacker_ciscobenben
2004-05-22 16:13:45
how a conversion method ? char   to   wchar  ?
wer123321
2004-05-22 16:32:26
on ATL string conversion macros. Very easy to use. Upstairs there are examples
sysdba2010
2004-05-22 16:46:06
landlord functions do not seem related to the conversion wchat_t and char , but a pointer comparison
If so there is no conversion necessary attention == and =

if you really want to compare strings are equal , use strcpy and wcscpy
converted into LPSTR LPWSTR by using the following functions
MultiByteToWideChar
taoweijiangting
2004-05-22 17:03:45
A2W   &   W2A do conversion
yangxiexun
2004-05-22 17:14:09
TN059:   Using   MFC   MBCS / Unicode   Conversion   Macros
duanjiahua
2004-05-22 17:29:14
use == to determine
life8795
2004-05-22 17:35:29
handwolf ( beginner )   practice can do
xumount
2004-05-22 17:55:20
= is a typo above

sorry I mean just want to make sure lpn value of this pointer is not the " this   is   string " or
" this is the string "
ATL or CSTRING

not ask what could be more simple way to use it for beginners sorry ?