Click here to Skip to main content
Licence 
First Posted 29 Jun 2002
Views 78,622
Bookmarked 14 times

CStringW and CStringA

By | 29 Jun 2002 | Article
CStringW and CStringA for WTL

Introduction

After doing endless string programming I got sick of doing string conversion and so split CString into a UNICODE and ANSI version (CStringW and CStringA). I replicated the WTL string class and replaced the internal data representation from TCHAR to wchar_t for CStringW and char for CStringA, modifying all functions depending on the internal data representation.

The classes behave exactly like CString. Just include "StringA.h" and "StringW.h" like you include "atlmisc.h". Even _ATL_MIN_CRT is supported. It's the same like MFC 7.0 is doing it, which gave me the inspiration by the way.

If you want to see unicode strings while debugging, don't forget to switch on Tools/Options/Debug/Display unicode strings. Which is not enabled by default.

Additionally you shoud modify your Autoexp.dat file to see the content of CStringW and CStringA like you are used from CString.

Add these two lines into the section [AutoExpand]:

CStringW =<m_pchData,su>
CStringA =<m_pchData,s>

Example

#include "StringA.h"
#include "StringW.h"

CStringW sTestW( L"Test" );
CStringA sTestA( "Test" );

// convert
CStringW sConvertW = sTestA;
CStringA sConvertA = sTestW;

I couldn't test all functions and probably some constructors are missing. If you find an error or have a suggestion please feel free and add a message to the discussion.

I hope you'll like and use it.
Oskar

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Oskar Wieland

Web Developer

Germany Germany

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralATL7.1 in WinDDK Pinmembermnjrupp8:05 7 Sep '10  
QuestionCompile Errors Pinmemberpscholl2:34 21 May '07  
Questionhow to CStrinA Pinmembersee_u_shree20:47 19 Jan '07  
AnswerRe: how to CStrinA Pinmembervlad.gs21:20 4 Feb '07  
GeneralConvert CString to UNICODE Pinmemberkiranin20:31 1 Dec '06  
AnswerRe: Convert CString to UNICODE PinmemberDrucik_22:41 19 Jan '07  
QuestionHow to copy CString to CStringA Pinmemberdharani20:12 22 Nov '06  
GeneralTHANK YOU!!!!! Pinmemberericb_summit6:03 10 Oct '05  
GeneralCStringW Format PinmemberDavid Smulders3:16 14 Jan '05  
GeneralROT COM Question PinmemberAlois Kraus3:31 3 Jan '03  
GeneralConfused PinmemberRashid Thadha22:23 30 Jun '02  
GeneralRe: Confused PinmemberPaul Selormey23:24 30 Jun '02  
GeneralRe: Confused PinmemberMagnus H3:25 1 Jul '02  
GeneralRe: Confused PinmemberMike Player3:42 1 Jul '02  
GeneralRe: Confused PinmemberMagnus H5:17 1 Jul '02  
GeneralRe: Confused PinmemberOskar4:14 1 Jul '02  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 30 Jun 2002
Article Copyright 2002 by Oskar Wieland
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid