Jump to content
  • Advertisement
Sign in to follow this  
SirLuthor

Unicode equiv. of __FILE__ etc.

This topic is 4844 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello once again good people! I have a query I'd like some help with.. I've done all the googling, searching, random messing around, etc, my poor mind can take for now, and still I have no answers.. Here's the deal.. I'm writing my core code in a way that is both usable with ASCII and UNICODE. However, predefined macros, such as __FILE__, __DATE__, etc are all non-unicode... So, I'm looking to see if there is a unicode version for these macros, because I'm in great need of it [smile] Also, just for the record, does anyone have some easy way to translate ASCII to Unicode, and back? Much obliged... Thanks!

Share this post


Link to post
Share on other sites
Advertisement
True, that's always an option, however, I believe that would only work if the project is set to use Unicode? I want my solution to work without having to do that? However, I do have my own #defines covering unicoding text, which look something like this below (I don't have the code with me right now), but don't work.. If someone would be so kind, could they point out what exactly is wrong with my version? This works with any other text, just not with the #defines mentioned...


// ASCSTRING is typedeffed to std::string or std::wstring depending on
// unicode/no unicode.
#ifdef ASC_UNICODE_
#define T(x) ASCSTRING( L##x## )
#else
#define T(x) ASCSTRING( x )
#endif


Share this post


Link to post
Share on other sites
Quote:
Original post by SirLuthor
[EDIT] WTF? deleted post?


was:

#define SMASH(x, y) x##y
#define WIDEN(x) SMASH(L,x)
#define WIDE_FILE WIDEN(__FILE__)
#define WIDE_DATE WIDEN(__DATE__)


then I realized the obvious _T(...) was already posted and that worked the problem I had was that I tried to use the 'L' modifier.

so in short _T(__FILE__) works just fine and I was a moron. [grin]

edit: using _T requires you to include tchar.h though.

Share this post


Link to post
Share on other sites
But does your version work? Because, like I mentioned in my earlier reply, I wish to avoid _T if at all possible, for reasons already spoken.

Share this post


Link to post
Share on other sites
MSDN recommends DigitalDelusion's version, so you may as well use that. THey didn't have the SMASH define though, so it was just:
#define WIDEN(x) L##x
#define WIDE_FILE WIDEN(__FILE__)

Share this post


Link to post
Share on other sites
Quote:
Original post by SirLuthor
But does your version work? Because, like I mentioned in my earlier reply, I wish to avoid _T if at all possible, for reasons already spoken.


Yep, it works just fine.

Share this post


Link to post
Share on other sites
Quote:
Original post by Promit
MSDN recommends DigitalDelusion's version, so you may as well use that.

wut? oh those bastards! stealing my precious IP before I even thought it up!



Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!