"Char" Standard Type
Char is the shared name used by Elements on all platforms and languages for the type used to represent a single UTF-16 character, as used standalone or in Strings. Chars are value types and in many ways the same as an unsigned 16-bit Integer – except in what they represent.
In C#, the char
keyword can also be used to refer to this type.
Literals
-
In Oxygene, char literals can be defined with single quotes, e.g.
'A'
. -
In Oxygene, you can also use a hash symbol (
#
), followed by either a decimal or a hexadecimal numeric value to write a char literal (without quotes):#65
or#$41
both also represent the letter "A". -
In C# and Java, char literals are also defined with single quotes, e.g.
'A'
. This can include the backslash escape symbol followed by a special character, such as'\n'
for a newline character (#10) or by 'x' or 'u' and a hexadecimal unicode character code, such as'\x0041'
. The backslash character itself also needs to be escaped, e.g.'\\'
represent a single backslash character. -
In Swift, string literals that are exactly one character in length (be it one actual character, or a backslash with a character code similar to C#) can be cast to a
Char
to become character literals.
Type Mappings
- On .NET,
Char
maps to theSystem.Char
FCL value type. - On Cocoa,
Char
maps to thewchar_t
type provided the C RTL. - On Java,
Char
maps to thechar
Java type. - On Island,
Char
is implemented in Island RTL asRemObjects.Elements.System.Char
.
AnsiChar
The AnsiChar
type is provided to support legacy 8-bit characters, where needed.