Skip to main content

Module utils

Module utils 

Source

Functions§

array_as_string
Convert a byte slice to a String (interpreting each byte as a char).
char_from_hex_code
Convert a hex code string (e.g., “20”) to the corresponding character.
copy_string_into_buffer
Copy a string’s bytes into a buffer at the given offset. Returns bytes written.
has_utf16_bom
Check if bytes start with a UTF-16 BOM (big-endian or little-endian).
merge_into_typed_array
Merge multiple byte slices into one Vec.
number_to_string
Convert a number to its string representation without scientific notation. This matches pdf-lib’s numberToString which avoids exponential notation.
pdf_doc_encoding_decode
Decode bytes using PDFDocEncoding to a String. PDFDocEncoding is essentially Latin-1 for bytes 0x00-0xFF, with some special mappings in the 0x80-0x9F range.
to_char_code
Convert a character to its char code (byte value).
to_hex_string
Convert a byte value to a two-digit uppercase hex string.
to_hex_string_of_min_length
Convert a number to a hex string with minimum length, zero-padded.
typed_array_for
Create a Vec from a string (each char’s lower byte).
utf16_decode
Decode UTF-16 bytes (with BOM) to a String.
utf16_encode
Encode a string as UTF-16BE with BOM.