"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):#65or#$41both 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
Charto become character literals.
Type Mappings
- On .NET,
Charmaps to theSystem.CharFCL value type. - On Cocoa,
Charmaps to thewchar_ttype provided the C RTL. - On Java,
Charmaps to thecharJava type. - On Island,
Charis implemented in Island RTL asRemObjects.Elements.System.Char.
AnsiChar
The AnsiChar type is provided to support legacy 8-bit characters, where needed.