base16384

Encode binary file to printable utf16be, and vice versa.

base16384
encoding
utf16be
moon add oboard/base16384@0.1.4
Download zip
Author
Version
0.1.4
License
Apache-2.0
Last updated
2 months ago
Downloads
29
README

#oboard/base16384

Version GitHub Workflow Status (with event) License

Encode binary file to printable utf16be, and vice versa.

It is a MoonBit reimplementation of base16384.

#API

fn decode(ArrayView[UInt16]) -> BytesView

fn decode_str(String) -> String raise

fn encode(BytesView) -> Array[UInt16]

fn encode_str(String) -> String

#Examples


///|
let input = "hello world"
let encoded = @base16384.encode_str(input)
let decoded = @base16384.decode_str(encoded)
inspect(encoded, content="栙擆羼湷槜瓆帀㴄")
inspect(decoded, content="hello world")

#
decode

fn decode(input : ArrayView[UInt16]) -> BytesView

Decodes a base16384-encoded array of 16-bit values back to the original byte data.

Parameters:

  • input : The array of 16-bit unsigned integers representing base16384-encoded data.

Returns an ArrayView[Byte] containing the decoded byte data. Returns an empty view if the input is empty or contains only the length marker.

#
decode_str

fn decode_str(input : String) -> String raise

Decodes a base16384-encoded string back to its original UTF-8 string representation.

Parameters:

  • input : The base16384-encoded string to decode.

Returns the original UTF-8 string.

Throws an error of type Error if the decoded bytes cannot be converted to a valid UTF-8 string.

#
encode

fn encode(input : BytesView) -> Array[UInt16]

#
encode_str

fn encode_str(input : String) -> String

Encodes a UTF-8 string into a base16384-encoded string representation.

Parameters:

  • input : The UTF-8 string to be encoded.

Returns a base16384-encoded string where each 16-bit value is stored as two consecutive bytes in little-endian format.

Source Files