please help us to convert PString object content to char * in VC++.
hi sir/modem Many thanks for your last regards, I have a problem about data conversion. i need to convert PString (a class exist in pstring.h inside ptlib package) object content to char * but How can i do this ? for more clearance i write the real code below: inline bool operator==(const PString & other) const { return CString::Compare(other); } i need to convert other object content to wchar_t * but when run this code it have below error in VC++ 2005 . error C2664: 'ATL::CStringT<BaseType,StringTraits>::Compare' : cannot convert parameter 1 from 'const PString' to 'const wchar_t *' Please help me to solve this problem. I am in wait for your response. Best regards. Zahra. Get your new Email address! Grab the Email name you've always wanted before someone else does! http://mail.promotions.yahoo.com/newdomains/aa/
Hi Here in the documentation http://www.opalvoip.org/docs/ptlib-v2_7/classPString.html. Section Conversion Functions u have a "operator const unsigned char *() const". This method converts PString in a char* string (PTLib uses multibyte string of chars -MBSC-) so for conversion is simple like: PString p("Hello World"); const char *p2 = (const char *)p; Regards. Marcos F. Jardini 2009/10/29 ZAHRA dehghanianfard <zahra_d84@yahoo.com>
hi sir/modem Many thanks for your last regards, I have a problem about data conversion. i need to convert PString (a class exist in pstring.h inside ptlib package) object content to char * but How can i do this ? for more clearance i write the real code below:
inline bool operator==(const PString & other) const { return CString::Compare(other); } i need to convert other object content to wchar_t * but when run this code it have below error in VC++ 2005 .
error C2664: 'ATL::CStringT<BaseType,StringTraits>::Compare' : cannot convert parameter 1 from 'const PString' to 'const wchar_t *'
Please help me to solve this problem. I am in wait for your response. Best regards. Zahra.
________________________________ New Email addresses available on Yahoo! Get the Email name you've always wanted on the new @ymail and @rocketmail. Hurry before someone else does!
-- ----- Jogue RPG, alimente o lado criativo!
You question says how to convert to char *, but the error is the conversion to wchar_t *. They are quite different. A PString is always UTF-8 (8 bits per character) and wchar_t is 16 bits (possibly more) per character. A CString in MFC is sometimes 8 bit sometimes 16 bit (UNICODE) depending on compiler options. Which makes coding tricky. So, if your code is guaranteed to always be using UNICODE CString just go other.AsUCS2() in your == operator. You can also look at the class PWideString for more. Robert Jongbloed OPAL/OpenH323/PTLib Architect and Co-founder. From: h323plus-bounces@lists.packetizer.com [mailto:h323plus-bounces@lists.packetizer.com] On Behalf Of ZAHRA dehghanianfard Sent: Thursday, 29 October 2009 9:00 PM To: h323plus Subject: [h323plus] please help us to convert PString object content to char * in VC++. hi sir/modem Many thanks for your last regards, I have a problem about data conversion. i need to convert PString (a class exist in pstring.h inside ptlib package) object content to char * but How can i do this ? for more clearance i write the real code below: inline bool operator==(const PString & other) const { return CString::Compare(other); } i need to convert other object content to wchar_t * but when run this code it have below error in VC++ 2005 . error C2664: 'ATL::CStringT<BaseType,StringTraits>::Compare' : cannot convert parameter 1 from 'const PString' to 'const wchar_t *' Please help me to solve this problem. I am in wait for your response. Best regards. Zahra. _____ New <http://sg.rd.yahoo.com/aa/mail/domainchoice/mail/signature/*http:/mail.prom otions.yahoo.com/newdomains/aa/> Email addresses available on Yahoo! Get the Email name you've always wanted on the new @ymail and @rocketmail. Hurry before someone else does!
participants (3)
-
Marcos Fábio Jardini
-
Robert Jongbloed
-
ZAHRA dehghanianfard