Public Group

# Unicode equiv. of __FILE__ etc.

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

## 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 on other sites
What's wrong with _T(__FILE__) ?

##### Share on other sites
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 on other sites
[EDIT] WTF? deleted 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 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 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 on other sites
Quote:
 Original post by SirLuthorBut 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 on other sites
Quote:
 Original post by PromitMSDN 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!

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 11
• 15
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
634151
• Total Posts
3015825
×