Difference between CString and CStringW

Ah hello.

My understanding of CString is that it is a class composed of a structure of TCHARs.  Now, TCHAR is defined as char or wchar_t depending on whether or not UNICODE is defined.

I still however see code using CStringW.  Hence my question: what is the difference between CString and CStringW; and when should I use which ?

TIA
LVL 19
mrwad99Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jkrCommented:
This is the ATL naming for the UNICODE version of CStringT, see http://msdn2.microsoft.com/en-us/library/5bzxfsea(VS.80).aspx ("CStringT Class")
0
mahesh1402Commented:
CStringW, CStringA, and CString are wide, ASCII, and TCHAR versions of CString.

CStringW always holds Unicode characters, independent of the compilation mode of the program.

e.g .
If you want to pass UNICODE string to a function, but have TCHAR or CString source, With VC7 you can use CStringW.

You may refer this : http://www.flounder.com/cstring.htm#Unicode%20and%20CStrings  <== Refer chart given at this section

MAHESH
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DanRollinsCommented:
Some of the techniques used with BSTR and MFC CString in the past no longer work with this new ATL-style CString.  See...
   ATL and MFC Changes: ATL 7.0 and MFC 7.0
   http://msdn2.microsoft.com/en-us/library/w1sc4t4k(vs.80).aspx
0
mrwad99Author Commented:
Thanks all :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.