String Type

A String value is a sequence of characters: numbers, letters, punctuation, symbols, and whitespace. In other programming languages, this type may be called "text" or "varchar". Examples include "fish" and "entrée." Emojis can be used, but the Windows console does not have the font support necessary to display them. Terminals on macOS and Linux can display emojis.
Literal strings are written with double quotes around them, as shown below.
dim x as String
x = "foo bar"
print "hello world!"
TMBASIC supports Unicode, a standard for representing world writing systems on computers. Strings are stored in memory using the UTF-16 encoding. This means that each distinct element in a string is a 16-bit "code unit." Either one or two 16-bit code units form a Unicode "code point." Unicode assigns a code point number to every character, accent, and symbol. In plain English text, a single letter or digit is one Unicode code point and is encoded in a single 16-bit code unit.


The Chr procedure will produce the character corresponding to a given code point number.
dim x = Chr(65) ' code point for "LATIN CAPITAL LETTER A"
print x ' prints: A
Some emojis, such as national flag emojis, are represented as a series of multiple code points. Accents may be represented by multiple Unicode code points known as combining diacritical marks. The following example demonstrates how combining marks may appear in strings.
dim x = Chr(101) ' code point for "LATIN SMALL LETTER E"
dim y = Chr(769) ' code point for "COMBINING ACUTE ACCENT"
dim z = x + y ' z is "é"


The Len procedure returns the number of 16-bit code units in a string. Keep in mind the caveats above about letters and symbols that are represented using multiple code points.
dim x = "hello"
dim y = Len(x) ' y is 5


Two strings can be combined (or "concatenated") using the + operator.
dim x = "aaa"
dim y = "bbb"
print x + y ' prints: aaabbb