0

This is the C++ code:

s.connect(L"TelldusClient");

I haven't seen this syntax before. I cannot find where L comes from and what it is. The header file gives:

void connect(const std::wstring &server);

So it seems like it is some sort of concatenation?

Bengt62
  • 137
  • 1
  • 7
  • L"x" is the compilers way for you to specify a Unicode string. MSVC also has a macro _T("x") which does either Unicode or ASCII depending on your project settings. – Jerry Jeremiah Mar 08 '14 at 22:00
  • possible duplicate of http://stackoverflow.com/questions/6384118/what-does-the-l-in-front-a-string-mean-in-c – pasztorpisti Mar 08 '14 at 22:01
  • possible duplicate of [What is a "wide character string" in C language?](http://stackoverflow.com/questions/11287213/what-is-a-wide-character-string-in-c-language) – mbschenkel Mar 08 '14 at 22:04

3 Answers3

1

L means the string should be interpreted as a wide string (Unicode).

As you can see, the function accepts wstring rather than a regular string, so the L is needed before the string.

In Windows, if you include tchar.h, you could also use _T("SomeString"), and this will be interpreted as "SomeString" if the code is compiled for ANSI, or L"SomeString" if it's compiled for Unicode.

Eran Zimmerman Gonen
  • 4,375
  • 1
  • 19
  • 31
0

L means that this string should be coded in Unicode.

Avt
  • 16,927
  • 4
  • 52
  • 72
0

This is wide string literal. For more details look at http://en.cppreference.com/w/cpp/language/string_literal

Wojtek Surowka
  • 20,535
  • 4
  • 44
  • 51