Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Difference between CString and CStringW

Posted on 2006-04-09
Medium Priority
Last Modified: 2013-11-20
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 ?

Question by:mrwad99
LVL 86

Assisted Solution

jkr earned 160 total points
ID: 16412059
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")
LVL 22

Accepted Solution

mahesh1402 earned 180 total points
ID: 16414905
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

LVL 49

Assisted Solution

DanRollins earned 160 total points
ID: 16421807
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
LVL 19

Author Comment

ID: 16426535
Thanks all :)

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question