CodeUnit Procedure

Returns the UTF-8 code unit at the specified index, or the first code unit if no index is specified. To convert a whole string to code units, use the CodeUnits function.
Warning: Correct usage of this function requires deep Unicode knowledge. Consider using the Characters function instead.

Overload #1: CodeUnit(input)

Declaration
function CodeUnit(input as String) as String

Parameters

Return value

String — The first UTF-8 code unit in input. If input is a zero-length string, then 0 is returned.

Example

Code
dim x = Chr(65) ' code point for "LATIN CAPITAL LETTER A"
print x
print CodeUnit(x)
Output
A
65

Overload #2: CodeUnit(input, index)

Declaration
function CodeUnit(
input as String, index as Number
) as String

Parameters

Return value

String — The first UTF-8 code unit in input. If index is out of range, then 0 is returned.

Example

Code
dim str = "ABCD"
dim unit = CodeUnit(str, 1)
print Chr(unit)
print unit
Output
B
66