Why do some ASCII characters take up more than 1 space in DataStores?

Just as a heads up, my networking skills are close to none. I can only write some basic database management code and use HTTP, but not much more, so don’t expect me to understand everything.

Going through the topic below, the author says that most of the control characters take up 6 spaces, while " and \ take up 2. Why is this the case? Were they just remapped to avoid developers accidentally causing errors or is there another reason?

The reason I’m asking is because I currently use a simple custom data format paired with an LZW implementation for my maps, but would like to increase its effectiveness.

1 Like

Its because \ is a control character, i.e its trying to convey metadata to the thing thats reading it. So what happens is you have to send some additional information to say “hey this isn’t a control character, treat it as plain text!”

I’m not dead certain about this, but I’m pretty sure thats why

2 Likes

But \ isn’t a control character. \ is used in many languages when creating a string, but \ itself is just a normal character that can be printed properly on every machine. By control characters I meant [NULL], [START OF HEADING], etc. Basically all the characters between 0-37 and 127.

Control characters are meant to represent something the software is supposed to accept as a command, not a simple character.

For example, NULL can be made in C and C++ with \0 and represents the end of your string. So, if your input is “test”, but without the \0 at the end, you will get something like “test23daw” when trying to print it.

See the quoted post below for more discussion.

Assuing that DataStores follow JSON encoding in this respect, the number of bytes required to store each character should be as follows:

Character Range (Decimal) Size (Bytes)
0 - 7 6
8 - 10 2
11 6
12 - 13 2
14 - 31 6
32 - 33 1
34 2
35 - 91 1
92 2
93 - 127 1
6 Likes