UTF8Len

UTF8Len 1:

The function returns the number of characters in a UTF-8 string.

If the string does not correspond to the UTF-8 format, the function returns the value 0.

In addition, the function checks whether all the characters are valid ASCII characters and outputs this via the bASCII output.

The function stops the verification after Tc2_Utilities.Parameterlist.cMaxCharacters. With appropriate parameterization an infinite loop can be avoided.

FUNCTION UTF8Len : UDINT

The return value returns the number of characters in the UTF-8 string.

UTF8Len 2: Inputs

VAR_INPUT
    pUTF8 : PVOID;
END_VAR

Name

Type

Description

pUTF8

PVOID

Pointer to the null-terminated UTF-8 string

UTF8Len 3: Outputs

VAR_OUTPUT
    bASCII   : BOOL;
    nSize    : UDINT;
END_VAR

Name

Type

Description

bASCII

BOOL

TRUE if the UTF-8 characters are valid ASCII characters.

nSize

UDINT

Size of the string in bytes (without null termination). Depending on the characters, the size in bytes may be larger than the length of the string.

UTF8Len 4:

Documentation for attribute 'TcEncoding' := 'UTF-8'

For more information about strings in UTF-8 format see also the documentation on the 'TcEncoding' attribute.

Requirements

Development environment

Target platform

PLC libraries to be integrated (category group)

TwinCAT v3.1.4022

PC or CX (x86, x64, ARM)

Tc2_Utilities (System) >= 3.3.21.0