Jump to content

CDuce/Types/Char

From Wikibooks, open books for an open world

The type Char corresponds to the set of all the Unicode characters.

Character literals

[edit | edit source]

A Unicode character literal is enclosed in single quotes :

'a'
'b'

Five special characters are escaped:

'\n'
'\t'
'\r'
'\''
'\\'

Arbitrary unicode value can be witten in decimal or hexadecimal way

'\55;'
'\055;'
'\x37;'
'\x0037;'
'7'

are corresponding all to the same character. Please note the mandatory ";".

As for the Int type, intervals of characters can be defined. The Byte type is defined in standard way by

type Byte = '\0;'--'\255;'

The types String and Latin1 are respectively defined as sequences of Char and Byte.

#print_type String;;
-> [ Char* ]
#print_type Latin1;;
-> [ Byte* ]