Node: Character Construction, Next: , Previous: Predicates on Characters, Up: Characters

Character Construction

codeChar code Function

codeChar given an integer code returns the Character object encoded as code. code can be an Lpp Integer, a C++ int or C++ character constant. For example in

     let char1 = codeChar('a');

char1 would be set to the Character object representing the C++ character constant 'a'. Note that the L operator can be used to do the same thing

     let char1 = L('a');

but it is not symmetric in the sense that the L operator applied to an int will return an Lpp Integer instead of an Lpp Character as codeChar will.

charCode character Function

charCodeL character Function

charCode returns an int that encodes the given Lpp Character character. charCodeL does the same but returns an Lpp Integer object. For example using the variable char1 above set to an Lpp Character object the following convert it to an Lpp Integer object, a C++ int and then to a C++ char

     let char1Integer = charCodeL(char1);
     int char1Int = charCode(char1);
     int char1Int = cL(char1);
     char char1Char = charCode(char1);
     char char1Char = cL(char1);

Note that the results of the cL operator is exactly equivalent to the charCode function, See To C++ Primitive Types.