-5

I gave the following Swift-code to ChatGPT:

let data = text.data(using: .utf8)

It answered me:

"This line takes your string and turns it into raw bytes (data) that can be stored, sent over the network, or written to a file."

The answer confused me more then it helped.

What's the difference between string and raw bytes?

I mean: Strings/Characters are only bits/bytes themself. What's the critical differentiation?

1
  • 2
    well, why don't you ask it "What's the difference between string and raw bytes?" and "What's the critical differentiation?" Commented Sep 14 at 6:39

1 Answer 1

5

01000011 01100001 01101110 00100000 01111001 01101111 01110101 00100000 01110010 01100101 01100001 01100100 00100000 01110010 01100001 01110111 00100000 01100010 01111001 01110100 01100101 01110011 00111111

Do you understand this? It's the string "Can you read raw bytes?" in binary representation organized in bytes (8 bits).

Of course you don't. Unlike machines humans are not used to read binary data.

A sequence of binary data can be something you can see like a picture or a video, something you can hear like an audio, or an application you can work with. These are representations of raw data.

Or it simply represents a string. The specific encoding is made for humans to get familiar letters and digits.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.