What is "L" for before a string in C++?

Asked

Viewed 36 times

4

I noticed that some frameworks and Engines require the string to be passed with L before the text. A Irrlicht Engine is an example.

myObject->setLabel(L"my string");

What is the purpose of this L in string?

  • 4

    it creates a string of type wchar_t in place a normal string (with type char), you can read more about it here: https://docs.microsoft.com/pt-br/cpp/cpp/char-wchar-t-char16-t-char32-t?view=msvc-160

  • 4

    This is a wide string (each character will be stored in multibyte) - do not confuse with utf 8 or 16, it is fixed size per character. As long as there’s no formal response, you can play along When choosing between using a string wide or not? for a reference.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.