Hi

In the unicode cases I use  "LPCTSTR" not CString, and I agree with Paul
about rather using new and delete functions instead of malloc.
/Mostafa

-----Original Message-----
From: Roel Vanhout [mailto:[EMAIL PROTECTED]
Sent: den 2 april 2004 10:32
To: [EMAIL PROTECTED]
Subject: [msvc] CString and unicode



Hello all,

I have recently tried to build one of my applications in a unicode 
configuration (by setting the character set in the configuration 
properties in the general page to 'unicode', I assume that defines the 
UNICODE and _UNICODE macros for me?). It's the first time I worked with 
it and so far it's been... let's say 'interesting'.
I read the chapter on Unicode in the 5th edition of the Petzold and the 
msdn general unicode documentation and that helped me through most 
problems. However I now have the problem that I have a library (a C dll) 
that want its arguments as const char* 's. I use ATL's CString 
throughout my program and I was wondering if there is any unicode 
conversion support in CString. What I do now is in the line of the 
following:

CString str("hello");
char* tmp = (char*)malloc(str.GetLength() + 1);
wcstombs(tmp, str, str.GetLength());
LibraryFuncCall(tmp);
free(tmp);

but as you can see this is a lot of work and it makes the code longer. 
Is there a shorter way? Also, wcstombs stands for 'wide character to 
multi-byte string' I believe; can I always (for applications with 
western codepages) consider 'multi-byte' to be 'ascii' ? Sorry if this 
mail reads confused, it's probably because I am ;) Thanks.

cheers,

roel


_______________________________________________
msvc mailing list
[EMAIL PROTECTED]
See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for
subscription changes, and list archive.

** Confidentiality Statement and Disclaimer **
Proprietary or confidential information belonging to Gambro AB or to one of
its affiliated companies may be contained in this message. If you are not
the addressee indicated in this message (or responsible for the delivery of
the message to such person), please do not copy or deliver this message to
anyone. In such case, please destroy this message and notify the sender by
reply e-mail. Please advise the sender immediately if you or your employer
do not consent to Internet e-mail for messages of this kind.
Opinions, conclusions and other information in this message that pertain to
the sender's employer and its products and services represent the opinion of
the sender and do not necessarily represent or reflect the views and
opinions of the employer. 
** End of Statement **


Reply via email to