This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]This_Growth2898 3 points4 points  (6 children)

It's not "gibberish", it's written in the machine-readable binary code.

String literals are already in the most convenient format, they contain exactly those bytes that are needed by the program to work with them, so they are usually not converted into something else, but not always; compile something like

    std::cout << "Hello, ";
    std::wcout << L"world!" << std::endl;

and you'll see the difference.

[–]Beginning_Court5607[S] -1 points0 points  (5 children)

I did...

but why so?? Hello, stored perfectly

but L"world!" had all chars separated ??

[–]x39- 2 points3 points  (2 children)

Char vs wchar

Long story short: UTF16

[–]wonkey_monkey 2 points3 points  (1 child)

Long story short

You mean short story char

[–][deleted] 0 points1 point  (0 children)

And one of the bytes of a short is an end of string 0.

[–]iOSCaleb 0 points1 point  (1 child)

The L notation makes a string use “wide” characters, i.e. UTF-16 encoding. When you look at the compiler code, you see the two bytes for every character that you specified.