Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 9th, 2006, 6:34 PM   #1
Cache
Hobbyist
 
Join Date: Sep 2005
Posts: 261
Rep Power: 4 Cache is on a distinguished road
Unicode & ANSI support w/ string & stringstream

What’s the usual/accepted way to achieve Unicode and ANSI support in Win32 programs with C++ string and stringstream classes? Is it best to write two versions of your code: one for ANSI and another for Unicode, or use some funky #ifdef’s and typedefs.

I was thinking for the latter, I could do something like this:
#include <string>
#include <sstream>

namespace lpr {
#if defined(UNICODE)
	typedef std::wstring		xstring;
	typedef std::wstringstream	xstringstream;
#else
	typedef std::string			xstring;
	typedef std::stringstream	xstringstream;
#endif	// UNICODE
}
Which might make the code seem odd, with things like ‘lpr::xstring’ all over the place, but it does seem to work well for supporting both ANSI and Unicode compilations.

Any suggestions?
Cache is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:24 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC