CODE_POINT_AT - Returns the code point at a position in a string

Help Contents

Introduction

Returns the Unicode code point at a position in a string.

Syntax

Informal Syntax:

CODE_POINT_AT( In, P )

Formal Syntax:

CODE_POINT_AT( In:=expression, P:=expression )

Parameters

ParameterTypeDescription
InANY_STRINGThe input string.
PANY_INTThe 1-based index of the code point to return.

The function is overloaded and accepts either the STRING or WSTRING type for the In parameter.

Return Value

The function CODE_POINT_AT returns a DINT value representing the Unicode code point value at position P.

If the In parameter is type STRING, the function will attempt to decode between 1 and 4 UTF-8 encoded bytes. If the In parameter is type WSTRING, the function will attempt to code 1 or 2 UTF-16 encoded words.

The function returns -1 if:

Examples

ExampleReturn Value
CODE_POINT_AT('Word', 1)DINT#87
CODE_POINT_AT('Word', 3)DINT#114
CODE_POINT_AT('Word', 4)DINT#0
CODE_POINT_AT('', 0)DINT#-1
CODE_POINT_AT('Word', -1)DINT#-1
CODE_POINT_AT(In:="Words", P:=3)DINT#114

Standards Compliance

The function CODE_POINT_AT is an extension to the IEC 61131-3 standard.

Further Information

String Functions

To learn about other String Functions.

String Literals

To learn about string literals and the different types of encoding used.

Common Elements

To learn about other IEC 61131-3 Common Elements.

Glossary

For the meaning of terms used in Fernhill SCADA.