-2
LPWSTR l = L"D:/MyFile.txt";    

I've searched everywhere, but couldnt find the answer. Thank you!

mboronin
  • 875
  • 1
  • 10
  • 16
  • This means it is wide char string i.e. UTF-16 in case of windows. – radar Oct 13 '14 at 16:26
  • _"I've searched everywhere"_ Honestly? I don't believe this! http://en.cppreference.com/w/cpp/language/string_literal – πάντα ῥεῖ Oct 13 '14 at 16:26
  • You probably also want to also check out the [`TEXT`](http://msdn.microsoft.com/en-us/library/windows/desktop/dd374074(v=vs.85).aspx) macro (it automates choosing the encoding for you according to compilation settings). – MasterMastic Oct 13 '14 at 16:27
  • Also: http://stackoverflow.com/questions/4870549/the-l-and-lpcwstr-in-windows-api – Ian Oct 13 '14 at 16:28
  • 3
    @MasterMastic, You probably don't unless you need to support very old versions of Windows. Use the wide API functions. – chris Oct 13 '14 at 16:28
  • It's not clear what exactly you're asking about. LPWSTR? See [this](http://msdn.microsoft.com/en-us/library/cc230355.aspx) (first result from google). The L prefix? See [here](http://stackoverflow.com/questions/13087219/what-exactly-is-the-l-prefix-in-c) (again, the first result when I googled for "L string prefix C++"). If you're actually asking about the string content: `"D:/MyFile.txt"` is a [Windows path](http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx). – bames53 Oct 13 '14 at 16:28
  • @chris I wouldn't necessarily do it for support, I'd do it because the encoding (for the most part) is an irrelevant implementation detail and I would discourage fixating on one or the other. I would also discourage using the wide API functions and encourage use the macros that will do the same for you (e.g. use `MessageBox` and not fixate on either `MessageBoxW` or `MessageBoxA`). – MasterMastic Oct 13 '14 at 16:34

1 Answers1

3

Long Pointer to Wide Character String. And you didn't search everywhere cause 1st google hit on LPWSTR points to MSDN:

The LPWSTR type is a 32-bit pointer to a string of 16-bit Unicode characters, which MAY be null-terminated. The LPWSTR type specifies a pointer to a sequence of Unicode characters, which MAY be terminated by a null character (usually referred to as "null-terminated Unicode").

typedef wchar_t* LPWSTR, *PWSTR;

And L in front of the literal specifies how the literal should be understood. It's kind of like suffixes for numeric types e.g: 10u, 4.0f. Because type is W (wchar_t), the appropriate counterpart for a literal definition is L.

Community
  • 1
  • 1
luk32
  • 15,812
  • 38
  • 62