English | 中文
QSLN (Quick Scratch List Notation) is a high-performance, lightweight, zero-escaping serialization format designed for two-dimensional list data (string[][]).
This format is primarily designed for the Scratch 3 environment.
-
Zero-Escaping: Values are stored as raw text. Any character—including semicolons (
;), newlines, quotes, or Unicode/emojis—can be safely stored inside values without escape characters like\or"". -
Scratch-Optimized (Ultra-Fast Loop String Concatenation): Scratch does not have native substring/slice blocks. QSLN’s length prefix allows Scratch to parse values through a tight, branchless
repeat (len)loop withjoin, achieving maximum execution efficiency via "Run without screen refresh" custom blocks. -
Mathematically Aligned with Safe Integers: A single hexadecimal character
H($0 \sim \text{f}$ ) represents decimal length strings from 1 to 16 characters in length, seamlessly covering the entire range from$0$ up toNumber.MAX_SAFE_INTEGER($2^{53} - 1 = 9007199254740991$ ). -
Compact & Lightweight: Short strings (
$\le 9$ characters) only add 2 overhead characters (0+ length).
All string lengths in this specification are based on JavaScript UTF-16 string length.
A QSLN document encodes a two-dimensional list of strings (string[][]). Each sublist ends with a semicolon (;).
[Element 1][Element 2]...;[Element 3]...;
| Field | Length | Type | Description |
|---|---|---|---|
H |
1 char | Hexadecimal ([0-9a-fA-F]) |
Length of Length String. Maps directly to the decimal digit count: |
Length |
|
Decimal Non-negative Integer ([0-9]) |
Character count of the raw value. Must consist purely of digits 0-9. |
Value |
Length chars |
Raw String | Verbatim content, extracted without any escaping or delimiter inspection. |
; |
1 char | Delimiter | Marks the end of a sublist. |
| H Character | Decimal Digits ( |
Value Length Range | Example Header |
|---|---|---|---|
0 |
1 digit |
00 (length 0), 05hello (length 5) |
|
1 |
2 digits |
127Quick Scratch List Notation (length 27) |
|
2 |
3 digits |
2100... (length 100) |
|
3 |
4 digits | Medium text / JSON payloads | |
... |
... | ... | ... |
9 |
10 digits | Near V8 engine max string memory limit (~1GB) | |
... |
... | ... | ... |
f |
16 digits | Up to |
Covers 9007199254740991) |
Data (string[][]) |
QSLN Encoded String | Description |
|---|---|---|
[["a", "b"], ["cd", "ef"]] |
01a01b;02cd02ef; |
Basic two-dimensional list |
[["hello;world"]] |
111hello;world; |
Embedded semicolon does not break parsing |
[[]] |
; |
Single empty list |
[[], []] |
;; |
Two consecutive empty lists |
[[""]] |
00; |
List containing one empty string |
[["", "x"]] |
0001x; |
Empty string alongside a non-empty string |
[["🎉 Scratch 🐱"]] |
113🎉 Scratch 🐱; |
Unicode and emoji support |
Open with TurboWarp editor:
https://turbowarp.org/editor?project_title=%5BQSLN%5D+Quick+Scratch+List+Notation&project_url=bddjr.github.io%2FQSLN%2F%5BQSLN%5D+Quick+Scratch+List+Notation.sb3
Scratch Project Link:
https://scratch.mit.edu/projects/1386520011/
Returned errors are placed in item 1 of QSLN.error.
If this item exists, the returned data is invalid.
If this item does not exist, no error occurred.
Variables, lists, and custom blocks starting with QSLN/internal. are for internal use by QSLN.
Do not call or modify them unless you know what you are doing.
Do not execute multiple QSLN custom blocks concurrently in the same sprite.
Use clones if concurrency is needed.
Custom block: QSLN.stringify
Input list:
QSLN.stringify.input
Input list.
Output variable:
QSLN.stringify.output
Output QSLN string.
This block does not return errors.
This block does not automatically clear QSLN.stringify.output in order to support two-dimensional lists.
You may need to manually clear the QSLN.stringify.output variable before calling this block.
Custom block: QSLN.parse
Input variables:
QSLN.parse.input.qsln
Input QSLN string.QSLN.parse.input.offset
The character position where parsing of the QSLN string begins.
To parse from the beginning, set the value to1.
The parsing process modifies the value of this variable, so you can useQSLN.parseas an iterator.
Output list:
QSLN.parse.output
Output list, where each item is a string.
Errors:
parse: Unexpected input offsetparse: Unexpected end of inputparse: Unexpected token '<char>' at position <offset>
You can use QSLN.parse as an iterator, calling it multiple times to parse multiple sublists.
See the js directory for details.
See the py directory for details.
This project is released into the public domain under The Unlicense.
The "Scratch" name is a trademark of the Scratch Foundation.