Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8362429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:56:24+00:00 2026-06-09T11:56:24+00:00

Is there a standard macro to convert a char string literal that is substituted

  • 0

Is there a standard macro to convert a char string literal that is substituted with a preprocessor macro to a wchar_t string using Visual Studio 2005?

e.g. this works:

wchar_t* test = L"Hello World";

but this doesn’t:

#define HELLOWORLD "Hello World"
wchar_t* test = L(HELLOWORLD);

I am sharing a header file containing many internationalised strings with several different projects on different platforms, so I don’t want to alter the header itself, nor add _T() since this is platform dependent. So I want the unicode conversion to be in my source, not in the header. I know I can write my own substitution macro as shown here, but am wondering if there is a standard method in VS?

This would seem a very common scenario for anyone writing internationalised code, but I can’t seem to find a predefined macro delivered with VS2005.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T11:56:26+00:00Added an answer on June 9, 2026 at 11:56 am

    No, there is no “standard” macro for this. The standard is to prefix wide strings with an L and omit the prefix from narrow strings.

    The only reason why such a macro even needs to exist is when you’re variously targeting platforms that don’t support Unicode. In that case, everything needs to be a narrow string. If you’re not dealing with platforms that lack Unicode support, then everything should probably be a wide string all the time.

    The _T and TEXT macros are provided in the Windows headers for precisely this purpose: maintaining a single code base that can be compiled both for Windows NT, which supports Unicode, and Windows 9x, which lacks Unicode support.

    I can’t imagine why you would need such a macro if you aren’t already including the Windows headers, but if you do, it’s pretty simple to write one yourself. Except than you’re going to need to know when string literals should be wide strings and when they should be narrow strings. There’s no “standard” #define for this, either. The Windows headers use the UNICODE pre-processor symbol, but you can’t rely on this being defined on other platforms. So now you’re back to where you started from.

    Why do you think you need a macro for this, again? If you’re hardcoding the type of the string as wchar_t*, then you’re always going to want to use a wide character literal, so you always want to use the L prefix.

    When you’re using the _T and/or TEXT macros from the Windows headers, you’re also not hard-coding the type of the string as wchar_t*. Instead, you’re using the TCHAR macro, which automatically resolves to the appropriate character type depending on the definition of the UNICODE symbol.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a standard way / C# library to convert a string into a
I'm looking for a Visual Studio 2008 add-in or macro that will examine all
Is there any standard way of debugging Javascript on a webpage that's being accessed
Is there a standard Java library that handles common file operations such as moving/copying
Is there a standard convention for the types of files that go in \Windows\
Is there a standard C function similar to strtol which will take a char*
Is there a standard or common way in C++ to handle static strings that
The ISO 1998 c++ standard specifies that not explicitly using a return statement in
There is an interesting coding standard in my shop that says that we don't
Are there standard file names for Terms of Use and Privacy Policies? For some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.