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
- input as String — The input string.
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)
print x
print CodeUnit(x)
Output
Overload #2: CodeUnit(input, index)
Declaration
function CodeUnit(
input as String, index as Number
) as String
Parameters
- input as String — The input string.
- index as Number — The 0-based index into input.
This should be between 0 and Len(input) - 1.
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