Credits | Overview | Plotting Styles | Commands | Terminals |
---|
The backslash character \ introduces an escape sequence representing a single character.
The form \X, where X is any single character, is handled differently in single- and double- quoted strings. See quotes. The "\X" is used verbatim in single-quoted non-enhanced text. In double-quoted text "\X" becomes "X" except for the special cases \n (newline) \r (return) and \t (tab).
The form \ooo, where ooo is a 3 digit octal value, can be used to index a known character code in a specific font encoding. This is mostly useful for the PostScript terminal because it cannot easily handle UTF-8 encoding. For example, PostScript output historically relied on the Adobe Symbol font, which uses a custom encoding in which octal 245 represents the infinity symbol. You could embed this in an enhanced text string by giving the font name and the character code "{/Symbol \245}". This mechanism may also remain useful to access characters in non-UTF8 fonts or locales.
You can specify a character by its Unicode code point as \U+hhhh, where hhhh is the 4 or 5 character hexadecimal code point. For example the code point for the infinity symbol ∞ is \U+221E. This will be converted to a UTF-8 byte sequence on output if appropriate. In a UTF-8 environment this mechanism is not needed for printable special characters since they are handled in a text string like any other character. However it is useful for combining forms or supplemental diacritical marks (e.g. an arrow over a letter to represent a vector). See utf8, string encoding, and the online unicode demo.
Since Unicode codepoints may consist of either 4 or 5 characters, the syntax would become ambiguous if a 4 character escape were immediately followed by another character than might be misinterpreted as being part of a 5 digit code. In such a case you must separate the escape sequence from the next character.
Example: Create a label "α1 + α2" enhanced text: set label "{\U+03B1}1 + {\U+03B1}2" enhanced non-enhanced text: set label "\U+03B1\1 + \U+03B1\2" noenhanced
Note that Unicode escape sequences are stored in a string without interpretation. The escape sequence is replaced by the character it represents when the string is printed or evaluated during substring processing. Thus after defining a string S = "A + \U+03A3 B", S[5:5] evaluates to "Σ" rather than "\", but (S eq S[1:*]) evaluates to FALSE because S holds the unprocessed escape sequence while evaluation of S[1:*] replaces the escape sequence with the UTF-8 byte sequence for Σ. Both will display as "A + Σ B" when used in a plot.