Difference between CString and CStringW

Posted on 2006-04-09
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

    This is the ATL naming for the UNICODE version of CStringT, see ("CStringT Class")
    LVL 22

    Accepted Solution

    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 :  <== Refer chart given at this section

    LVL 49

    Assisted Solution

    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

    Thanks all :)

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
    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.
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    755 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

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now