# LGF_EncodeUtf8 (FC / 1.0.0)

Overview

Author: Siemens Online Support

## Short description

Encodes a WString into an UTF-8 encoded byte stream.

### Block Interface

| LGF_EncodeUtf8 (FC) |
--- | --- | ---
WString |  |  | sourceString |  | Ret_Val |  |  | Word
DInt |  |  | startPos |  | bytesUsed |  |  | UInt
Array[*] of Byte |  |  | encodedByteStream |  |  | Array[*] of Byte

### Input parameter

Identifier | Data type | Description
--- | --- | ---
sourceString | WString | Character that shall be converted to UTF-8
startPos | DInt | Position in encoded byte stream to start insert encoded WChars (Array lower bound is added)

### Output parameter

Identifier | Data type | Description
--- | --- | ---
Ret_Val | Word | 16#0000 - 16#7FFF: Status of the FC, 16#8000 - 16#FFFF: Error identification
bytesUsed | UInt | Number of Bytes converted. Ranges from 1 to 3.

### In/Out parameter

Identifier | Data type | Description
--- | --- | ---
encodedByteStream | Array[*] of Byte | UTF-8 conformant byte sequence. B0 stores first Byte, B1 second and B2 third Byte. B3 is not used

### Status & Error codes

Code / Value | Identifier / Description
--- | ---
16#0000 | STATUS_NO_ERROR Status: No error
16#8201 | ERR_START_POS_OUTSIDE Error: Parameter `startPos` is outside array bounds
16#8202 | ERR_COUNT_EXCEEDS_BOUNDS Error: Lenght of array reached

## Change log

Version & Date | Change description
--- | ---
| 1.0.0 | Siemens Online Support
| 2022-12-16 | First released version