Text
The Text Data Type is used to represent just that: text. Among its many uses, it displays text in a Label to capture data from users, such as their phone number or email address, or representing Data Types that do not exist, such as a color.
A string can be entered into an Airscript Expression by enclosing the text inside double quotes. For example, to create a Text Variable containing the string "The quick brown fox" one would write the Airscript Expression as follows:
"The quick brown fox"
Dynamic content can also be embeded inside a Text Variable. Text Variable literals support embedding the result of an arbitrary Airscript Expression by enclosing the Expression inside {{ and }}. This is called Text Interpolation. For example, for a variable named count that contains a Number, you can embed the value of that Variable this way:
"The count is: \{{FORMAT_NUMBER(count, "#")}}"
In order to create a text literal that contains a double quote "" it is necessary to escape the double quote by preceding it with a backslash . For example:
"\"Airkit is the coolest\" said Mary."
This is done to differentiate a double quote that should be a part of the Text content vs a double quote that marks the end of the string. In addition to \ Airscript supports the following escape sequences.
Escape | Ouput |
---|---|
" | A double quote character '"' |
\ | A backslash character '' |
\n | A newline |
\r | A carriage return |
\v | A vertical tab |
\t | A horizontal tab |
\b | A backspace |
\f | A form feed |
{{ | The characters '{{' |
Internally, Text is stored as random access sequences of UTF-16 code points. For many characters, this means that each character takes up one slot in the string. However, some characters may take two slots. For example, the grinning face emoji '😃' has a length of two rather one.