rans_decode
result = rans_decode(enc, [as_str=false])
Input: enc, as_str · Output: result
What it is
Inverse of rans_encode: enc is the Record that call returned; as_str (named boolean, default false) asks for text instead of bytes.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = rans_decode(enc, [as_str=false]) | enc RecordInverse of rans_encode: enc is the Record that call returned.as_str boolean, optional (default false)as_str (named boolean, default false) asks for text instead of bytes. | result Vec, number, or Str | Returns a Vec of 0-255 numbers, or the decoded text as a Str when as_str = true. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
s = "hello hello hello compression world"
enc = rans_encode(s)
print(numel(enc.bytes)) # coded length, in bytes
print(rans_decode(enc, as_str = true) == s) # true
output
18 true
from file-io