Mercury Programming/Types

Char
A value of type  is a single unicode character (implemented using UTF8 encoding and so may occupy 1 to 4 bytes). There are several ways to specify a  as a literal value:


 * As an ordinary character between single quotes, for example  - unless:
 * the character is a single quote, in which case use 4 single quotes:, or use 3 single quotes and with a backslash as the second character:.
 * the character is a backslash, in which case use 2 backslashes between single quotes:.
 * the character is the double quote, in which case put it between single quotes: , or give it a leading backslash and put them between single quotes:.


 * As a hexadecimal value giving the Unicode code point (see Unicode) of the required character; the hexadecimal value must have a leading 'x', placed between '\' characters, which are in turn placed between single quotes, for example  (equivalent to the character 'c').


 * As an octal value giving the Unicode code point of the required character; the octal value must be placed between '\' characters, which are in turn placed between single quotes, for example  (equivalent to the character '©').


 * As a 4 digit hexadecimal value giving the Unicode code point of the required character; the value must be prefixed with '\u', and the result placed between single quotes, for example  (equivalent to the Greek lower case character μ).


 * As an 8 digit hexadecimal value giving the Unicode code point of the required character; the value must be prefixed with '\U', and the result placed between single quotes, for example  (equivalent to the character '±'). Note that the highest allowed value is.


 * Several special characters can be specified as shown in the table below:

A simple Mercury program demonstrating  literals is in Section A.1