Note: information on this page refers to Ceylon 1.1, not to the current release.

Character literals

A literal notation for a Character value.


A Character literal is a single character enclosed in paired single quotes, for example:

Character x = 'x';
Character quote = '\'';



A character literals may contain an escape sequences. Backslash is used as an escape character. The following characters must be escaped when they're used within a plain String literal:

  • backslash, \, must be written as \\
  • single quote, ', must be written as \'
  • backtick, `, must be written as \`

The following traditional C-style escape sequences are also supported:

  • tab, \t
  • newline, \n
  • return, \r
  • form feed, \f
  • backspace, \b
  • double quote, \"

Unicode Escapes

You can use Unicode escapes within character literals. Like this, identifying a Unicode character using a hexadecimal code:

Character therefore = '\{#2234}'; // Unicode therefore symbol

Or, alternatively, using the Unicode character name:

Character therefore = '\{THEREFORE}';

Of course, you can directly embed a Unicode character in a Character literal:

Character therefore = '∴';

But this is highly discouraged, since it causes problems when sharing source code across operating systems with different default character encodings.

See also