Re: L macro
- From: "Giovanni Dicanio" <giovanni.dicanio@xxxxxxxxxx>
- Date: Mon, 20 Aug 2007 17:57:38 +0200
"George" <George@xxxxxxxxxxxxxxxxxxxxxxxxx> ha scritto nel messaggio
news:5B63A9B8-4712-4219-AC85-C302CAC4F2E2@xxxxxxxxxxxxxxxx
Could anyone explain how to use L macro in Visual Studio 2003 and Windows
Console project? Which header file is needed?
L is not a macro, it is a prefix for strings, to tell the compiler that the
L-prefixed string is a Unicode UTF-16 string (so it is an array of 16 bits
WCHAR-s and not of 8 bits char-s).
e.g.
"Hello": ANSI string, stored as: 'H' 'e' 'l' 'l' 'o' '\0'
L"Hello": Unicode UTF-16 string, stored as L'H' L'e' L'l' L'l' L'o' L'\0'
(i.e. a sequence of 16 bits WCHAR-s).
So, if you want to use Unicode UTF-16 strings in your app, you should put
the L prefix, as shown above.
There is also a preprocessor macro, called _T (to be used like so:
_T("Hello") ), which evaluates to nothing on ANSI builds, and to L on
Unicode builds.
Note that, if you use resource string-tables and CString::LoadString method
to load strings from resources, you won't need the L"..." thing, and your
app's localization will also be easier, IMHO.
Giovanni
.
- Follow-Ups:
- Re: L macro
- From: Alexander Nickolov
- Re: L macro
- Prev by Date: Re: LPCSTR and LPCWSTR
- Next by Date: Re: Correct location for .PDB File when separating libs from binaries
- Previous by thread: Re: LPCSTR and LPCWSTR
- Next by thread: Re: L macro
- Index(es):
Relevant Pages
|
Loading