Discussion:
How to convert CString to ASCII character string?
(too old to reply)
jt
2005-07-14 04:07:01 UTC
Permalink
Looking for an example how to convert and CString to an ASCII character
string.

Any examples on how to do this?

Thank you,
jt
Alexander Grigoriev
2005-07-14 04:38:29 UTC
Permalink
There is an implicit CString::operator LPCTSTR() const, for example, which
returns a const pointer to the string.
Post by jt
Looking for an example how to convert and CString to an ASCII character
string.
Any examples on how to do this?
Thank you,
jt
Nishant Sivakumar
2005-07-14 04:42:21 UTC
Permalink
In the previous thread, several people had offered solutions that you seem
to have ignored. Anyway here's the code once more :-

//assuming a Unicode build
CString str = _T("Some Unicode string");
char ascstr[32];
USES_CONVERSION;
strcpy(ascstr, CT2CA(str));
//Now ascstr contains an ANSI version of the string that was in str.
--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
Post by jt
Looking for an example how to convert and CString to an ASCII character
string.
Any examples on how to do this?
Thank you,
jt
jt
2005-07-15 01:55:57 UTC
Permalink
The compiler says, error C2065: 'CT2CA' : undeclared identifier

Is there a header file that I need to include?

Thanks,
jef
Post by Nishant Sivakumar
In the previous thread, several people had offered solutions that you seem
to have ignored. Anyway here's the code once more :-
//assuming a Unicode build
CString str = _T("Some Unicode string");
char ascstr[32];
USES_CONVERSION;
strcpy(ascstr, CT2CA(str));
//Now ascstr contains an ANSI version of the string that was in str.
--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
Post by jt
Looking for an example how to convert and CString to an ASCII character
string.
Any examples on how to do this?
Thank you,
jt
Nishant Sivakumar
2005-07-15 04:40:30 UTC
Permalink
Uhm I guess you are using VC++ 6?
--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
Post by jt
The compiler says, error C2065: 'CT2CA' : undeclared identifier
Is there a header file that I need to include?
Thanks,
jef
Post by Nishant Sivakumar
In the previous thread, several people had offered solutions that you
seem to have ignored. Anyway here's the code once more :-
//assuming a Unicode build
CString str = _T("Some Unicode string");
char ascstr[32];
USES_CONVERSION;
strcpy(ascstr, CT2CA(str));
//Now ascstr contains an ANSI version of the string that was in str.
--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
Post by jt
Looking for an example how to convert and CString to an ASCII character
string.
Any examples on how to do this?
Thank you,
jt
Nishant Sivakumar
2005-07-15 04:49:53 UTC
Permalink
Here's the code for VC6 :-

//assuming a Unicode build
CString str = _T("Some Unicode string");
char ascstr[32];
USES_CONVERSION;
strcpy(ascstr, T2CA(str));
//Now ascstr contains an ANSI version of the string that was in str.
--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
Post by jt
The compiler says, error C2065: 'CT2CA' : undeclared identifier
Is there a header file that I need to include?
Thanks,
jef
Post by Nishant Sivakumar
In the previous thread, several people had offered solutions that you
seem to have ignored. Anyway here's the code once more :-
//assuming a Unicode build
CString str = _T("Some Unicode string");
char ascstr[32];
USES_CONVERSION;
strcpy(ascstr, CT2CA(str));
//Now ascstr contains an ANSI version of the string that was in str.
--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
Post by jt
Looking for an example how to convert and CString to an ASCII character
string.
Any examples on how to do this?
Thank you,
jt
German
2005-07-15 23:19:04 UTC
Permalink
Masters :

Please, what does T2CA mean ?
Thank in advanced

German Medina
+519-662-8500
Post by Nishant Sivakumar
Here's the code for VC6 :-
//assuming a Unicode build
CString str = _T("Some Unicode string");
char ascstr[32];
USES_CONVERSION;
strcpy(ascstr, T2CA(str));
//Now ascstr contains an ANSI version of the string that was in str.
--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
Post by jt
The compiler says, error C2065: 'CT2CA' : undeclared identifier
Is there a header file that I need to include?
Thanks,
jef
Post by Nishant Sivakumar
In the previous thread, several people had offered solutions that you
seem to have ignored. Anyway here's the code once more :-
//assuming a Unicode build
CString str = _T("Some Unicode string");
char ascstr[32];
USES_CONVERSION;
strcpy(ascstr, CT2CA(str));
//Now ascstr contains an ANSI version of the string that was in str.
--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
Post by jt
Looking for an example how to convert and CString to an ASCII character
string.
Any examples on how to do this?
Thank you,
jt
Victor
2005-07-17 19:02:14 UTC
Permalink
It means "convert from LPCTSTR to LPCSTR".
See MSDN for details.

Regards,
Victor
Post by German
Please, what does T2CA mean ?
Thank in advanced
German Medina
+519-662-8500
Post by Nishant Sivakumar
Here's the code for VC6 :-
//assuming a Unicode build
CString str = _T("Some Unicode string");
char ascstr[32];
USES_CONVERSION;
strcpy(ascstr, T2CA(str));
//Now ascstr contains an ANSI version of the string that was in str.
--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
Post by jt
The compiler says, error C2065: 'CT2CA' : undeclared identifier
Is there a header file that I need to include?
Thanks,
jef
Post by Nishant Sivakumar
In the previous thread, several people had offered solutions that you
seem to have ignored. Anyway here's the code once more :-
//assuming a Unicode build
CString str = _T("Some Unicode string");
char ascstr[32];
USES_CONVERSION;
strcpy(ascstr, CT2CA(str));
//Now ascstr contains an ANSI version of the string that was in str.
--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
Post by jt
Looking for an example how to convert and CString to an ASCII
character
Post by German
Post by Nishant Sivakumar
Post by jt
Post by Nishant Sivakumar
Post by jt
string.
Any examples on how to do this?
Thank you,
jt
jt
2005-07-16 01:38:07 UTC
Permalink
It fails to compile. Is there a header file that I need to include?
Post by Nishant Sivakumar
Here's the code for VC6 :-
//assuming a Unicode build
CString str = _T("Some Unicode string");
char ascstr[32];
USES_CONVERSION;
strcpy(ascstr, T2CA(str));
//Now ascstr contains an ANSI version of the string that was in str.
--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
Post by jt
The compiler says, error C2065: 'CT2CA' : undeclared identifier
Is there a header file that I need to include?
Thanks,
jef
Post by Nishant Sivakumar
In the previous thread, several people had offered solutions that you
seem to have ignored. Anyway here's the code once more :-
//assuming a Unicode build
CString str = _T("Some Unicode string");
char ascstr[32];
USES_CONVERSION;
strcpy(ascstr, CT2CA(str));
//Now ascstr contains an ANSI version of the string that was in str.
--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
Post by jt
Looking for an example how to convert and CString to an ASCII
character string.
Any examples on how to do this?
Thank you,
jt
Victor
2005-07-17 19:04:58 UTC
Permalink
Yes! Seethe "TN059: Using MFC MBCS/Unicode Conversion Macros" article in
MSDN ....

Regards,
Victor
Post by jt
It fails to compile. Is there a header file that I need to include?
Post by Nishant Sivakumar
Here's the code for VC6 :-
//assuming a Unicode build
CString str = _T("Some Unicode string");
char ascstr[32];
USES_CONVERSION;
strcpy(ascstr, T2CA(str));
//Now ascstr contains an ANSI version of the string that was in str.
--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
Post by jt
The compiler says, error C2065: 'CT2CA' : undeclared identifier
Is there a header file that I need to include?
Thanks,
jef
Post by Nishant Sivakumar
In the previous thread, several people had offered solutions that you
seem to have ignored. Anyway here's the code once more :-
//assuming a Unicode build
CString str = _T("Some Unicode string");
char ascstr[32];
USES_CONVERSION;
strcpy(ascstr, CT2CA(str));
//Now ascstr contains an ANSI version of the string that was in str.
--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
Post by jt
Looking for an example how to convert and CString to an ASCII
character string.
Any examples on how to do this?
Thank you,
jt
Loading...