code

Prev Next

Function Names

code

Description

This function returns the UNICODE character code of the character supplied.

Call as: function

Restrictions

Indirect parameter passing is disabled

Parameter count

1-2

Parameters

No.TypeDescription
1
input
string input string

Input string containing character to decode

Opt. 2
input
numeral character position

Character position, if a character other than the 1st character needs to be decoded. Negative indexing: Negative values count from right to left, e.g. -1 = last character.

Default value: 0

Return value

TypeDescription
numeral character code

>0: UNICODE character code
0: Empty string
-1: Attempted to decode character at positition outside the string

Examples

      echo( code( 'Café 4.0 €' ) ); // C
      echo( code( 'Café 4.0 €', 3 ) ); // é
      echo( code( 'Café 4.0 €', -1 ) ); // €
      echo( code( 'Café 4.0 €', 99 ) ); // -1 (out of bounds)
      echo( code( '𝄞' ) ); // Violin clef
      echo( code( '' ) ); // 0 returned

Output

67
233
8364
-1
119070
0
Try it yourself: Open LIB_Function_code.b4p in B4P_Examples.zip. Decompress before use.

See also

chr