Data Object

A Data object holds a sequence of uninterpreted bytes. 

Data objects are most often created by reading file data from disk. The following are some commands that create them:

File.readDataFromPath

Encode RTF

When used in a text context, data objects are automatically coerced to a string using an automatically selected text encoding, eg:

$data = File.readDataFromPath("~/Desktop/test.txt")

Prompt $data

Some commands expect IANA text encoding names as arguments. These are standardized text encoding names that are officially recognized. For example, "Shift_JIS" or "UTF-8". For a full list, see this online list of encoding names. The Nisus macro language may accept non-official names, so long as they are recognized by macOS. For example "MacRoman" seems to be recognized. If a given text encoding name is unknown an error is shown.

Data Object Properties

.byteCount v2.1.2

Returns the size of the data, ie: its number of bytes.

Data Object Commands

.convertToString [textEncodingName] v2.1.2

Converts the data from a raw uninterpreted sequence of bytes to a proper string.

Optionally an IANA text encoding name may be given. If no text encoding name is given, a text encoding is selected automatically.

If the data is invalid for the target encoding this command returns the undefined value.


Previous Chapter
Primitive Objects
<<  index  >>
 
Next Chapter
Date Object