Unicode equiv. of __FILE__ etc.

Started by
7 comments, last by DigitalDelusion 18 years, 8 months ago
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!
Free speech for the living, dead men tell no tales,Your laughing finger will never point again...Omerta!Sing for me now!
Advertisement
What's wrong with _T(__FILE__) ?
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
Free speech for the living, dead men tell no tales,Your laughing finger will never point again...Omerta!Sing for me now!
[EDIT] WTF? deleted post?
Free speech for the living, dead men tell no tales,Your laughing finger will never point again...Omerta!Sing for me now!
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.
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats
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.
Free speech for the living, dead men tell no tales,Your laughing finger will never point again...Omerta!Sing for me now!
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__)
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
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.
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats
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!



HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats

This topic is closed to new replies.

Advertisement