At some time when making your game you will need to use text. Text in games is dealt with by using the string functions (a string is just another way of saying a line of text) and GameMaker Studio 2 has a complete set of functions that permit you to manipulate strings in many ways, including the insertion of one string in another, the copying of strings and the ability to parse strings for the digits or the letters that they contain. In general a string can only be created by adding text within double quotes " " and single quote strings are not accepted, nor can you split the string over multiple lines and expect GameMaker Studio 2 to render it as if the line breaks were newlines (unless a string literal @ identifier is used, as explained below).
It is worth noting that there are certain conventions that you can use when creating strings, mostly concerned with using escape characters. These are characters that are preceded by a "\" symbol. So, for example, if you wanted to put quotation marks within a string you would have something like this:
str = "Hello\"World\"";
You can use the "\" to precede any Unicode literal - 4 digits of hex following a "u", for example "\u0000", where the 4 digits are the number of the Unicode character - or any hexadecimal literal - 2 digits of hex following a "0x", for example "\xff", where the 2 digits are the number of the character to use. These and other predefined escape characters are listed in the table below:
|\f||Form Feed (0x0c)|
|\t||Horizontal Tab (0x09)|
|\v||Vertical Tab (0x0b)|
|\\||Backslash itself (0x5c)|
|\u[Hex Digits]||Insert hex unicode character (note max 4 digits)|
|\x[Hex Digits]||Insert hex unicode character|
|\[Octal Digits]||Insert octal unicode character|
You can also create verbatim string literals by preceding the whole string with the @ character:
var test = @"
The above code will render the string over multiple lines as if there was a line break escape character included. A verbatim string literal is similar to previous GameMaker version string literals but they also use double or single quotes and must be prefixed by an @ symbol, they can be broken over multiple lines in the code file and they DO NOT support escaped characters i.e. @"Hello\World" will NOT try to escape the W on World and will be stored verbatim. Note though that when using string literals like this, you will need to break the string if you wish to include quotation marks as part of the string, ie:
var test = @"Hello " + "\"" + @"World" + "\""
Another thing to note is that the unicode character 9647 (▯) is used to substitute any missing glyphs that you may have in your designated font when rendering it in the draw event. So if your font doesn't have, for example, the ° symbol, then writing 90° will actually produce 90▯.
The following list of functions are all for dealing with strings:
Other than those functions that relate specifically to strings, the Windows target also permits you to use access the clipboard to get and set text information: