Module dctext

Module dctext 

Source
Expand description

Implements DcText and related formats DcList and DcUTF. These formats are encodings for sequences of integer global graph IDs (which are long Dcs). Format looks like (w/o backticks): Unicode (UTF-8) text @123@miesu@214748364@@L662@ where Unicode text is actual unicode text, and between each pair of @ signs, is a DcId. A DcId can be any int 128 bits (u128) in decimal, and it may have an L prefix. Output format is sort of UTF-8 text. For normal Unicode input characters, the output character is the same. For DcIds less than or equal to 1114111 (the largest Unicode character, I believe), the output character is the corresponding “generalized UTF-8”, the numeric value encoded in the same underlying algorithm as UTF-8. For DcIds greater than 1114111 and not prefixed with an L, the output character is the decimal DcId represented by extending the usual algorithm of UTF-8 encoding, but for those larger numbers. For DcIds prefixed with an L, the output is equivalent to @1114408@ (short Dc 296) followed by a Dc number for the number that followed the L (the L is just a shorthand for that 1114408 Dc). That is to say, it’s not a true Unicode encoding, it’s simply using an extension of the algorithm underlying UTF-8 as a convenient encoding of ints. Currently, DcList is used as the internal format for pivoting between other formats, but DcUtf might make more sense eventually for space efficiency.

Functions§

dcarray_to_dclist
Converts an EITE DcArray (short Dcs, &[u32]) to a DcList (Vec<u128>).
dcarray_to_dcstring
Parses a DcText document (&[u8]) directly into a DcString.
dcarray_to_dctext
Converts an EITE DcArray (short Dcs, &[u32]) to the DcText format (Vec<u8>).
dclist_to_dcarray
Converts a DcList (&[u128]) to an EITE DcArray (short Dcs, Vec<u32>).
dclist_to_dctext
Serializes a DcList (&[u128]) to DcText format bytes (Vec<u8>).
dclist_to_dctext_with_resolver
Serializes a DcList (&[u128]) to DcText format bytes (Vec<u8>) using the given resolver.
dclist_to_dctf
Converts a DcList (&[u128]) to DcTF bytes.
dclist_to_dcutf
Converts a DcList (&[u128]) to legacy generalized UTF-8 bytes (DcUtf).
dcmstring_to_dctext
Converts a DcMstring to DcText bytes.
dcstring_to_dcarray
Converts a DcStr to an EITE DcArray (short Dcs, Vec<u32>).
dcstring_to_dctext
Serializes a DcStr to DcText format bytes (Vec<u8>).
dctext_to_dcarray
Converts a DcText document (&[u8]) to an EITE DcArray (short Dcs, Vec<u32>).
dctext_to_dclist
Parses a DcText document (&[u8]) into a DcList (Vec<u128>).
dctext_to_dcmstring
Converts a DcText document to DcMstring.
dctext_to_dcmstring_with_options
Converts a DcText document to DcMstring, optionally in permissive mode.
dctext_to_dcstring
Parses a DcText document (&[u8]) into a DcList (Vec<u128>).
dctext_to_dctf
Converts DcText format bytes to DcTF format bytes.
dctext_to_dcutf
Converts DcText format bytes to legacy DcUtf format bytes.
dctf_to_dclist
Decodes DcTF bytes into a DcList (Vec<u128>).
dctf_to_dctext
Converts DcTF format bytes to DcText format bytes.
dcutf_to_dclist
Decodes generalized UTF-8 bytes (DcUtf) into a DcList (Vec<u128>).
dcutf_to_dctext
Converts legacy DcUtf format bytes to DcText format bytes.
format_blob_preview
Formats a byte slice as a displayable preview string. If is_dctext is true, first converts DcText to plain text. If the text is displayable (only graphic/whitespace chars), truncates it to 60 chars and returns it. Otherwise, returns a <binary data: N bytes> preview.

Type Aliases§

DcList
A list of global graph Document Character IDs represented as u128 values.