handling CString in unicode
-
I have to convert CString to integer under unicode debugging as below... CString str = "123"; #ifdef _UNICODE int i = atoi(str); #endif throws the error C2664: 'atoi' : cannot convert parameter 1 from 'class CString' to 'const char *' Kindly tell me how to do this? :rolleyes:
-
I have to convert CString to integer under unicode debugging as below... CString str = "123"; #ifdef _UNICODE int i = atoi(str); #endif throws the error C2664: 'atoi' : cannot convert parameter 1 from 'class CString' to 'const char *' Kindly tell me how to do this? :rolleyes:
Use the
W2A()
macro, as in:int i = atoi(W2A(str));
Don't forget the
USES_CONVERSION
statement.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
-
Use the
W2A()
macro, as in:int i = atoi(W2A(str));
Don't forget the
USES_CONVERSION
statement.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
-
Or use the new vc7 conversion macros, CW2A in this case, no need for USES_CONVERSION then. /Magnus
- I don't necessarily agree with everything I say
Assuming that VC7 is being used.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
-
Assuming that VC7 is being used.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
-
I have to convert CString to integer under unicode debugging as below... CString str = "123"; #ifdef _UNICODE int i = atoi(str); #endif throws the error C2664: 'atoi' : cannot convert parameter 1 from 'class CString' to 'const char *' Kindly tell me how to do this? :rolleyes:
use _wtoi(...) this accepts widechar bytes.
MSN Messenger. prakashnadar@msn.com Tip of the day of visual C++ IDE. "We use it before you do! Visual C++ was developed using Visual C++"
-
use _wtoi(...) this accepts widechar bytes.
MSN Messenger. prakashnadar@msn.com Tip of the day of visual C++ IDE. "We use it before you do! Visual C++ was developed using Visual C++"
If you use _ttoi, it will use ANSI or wide characters as required, depending on whether you are doing a Unicode build or not (ie if _UNICODE is #defined or not)