# LGF_DecodeUtf8 (FC / 1.0.0)

Overview

Author: Siemens Online Support

## Short description

Decodes a UTF-8 encoded byte stream into a WString

### Block Interface

| LGF_DecodeUtf8 (FC) |
--- | --- | ---
Array[*] of Byte |  |  | byteStream |  | Ret_Val |  |  | Word
DInt |  |  | startPos |  |  |  |  |
UInt |  |  | count |  |  |  |  |
WString |  |  | decodedString |  |  | WString

### Input parameter

Identifier | Data type | Description
--- | --- | ---
byteStream | Array[*] of Byte | UTF-8 encoded byte stream
startPos | DInt | Position in byte stream to start decoding from
count | UInt | Number of character (not bytes) to decode; 0: byte stream is decoded until end

### Output parameter

Identifier | Data type | Description
--- | --- | ---
Ret_Val | Word | 16#0000 - 16#7FFF: Status of the FC, 16#8000 - 16#FFFF: Error identification

### In/Out parameter

Identifier | Data type | Description
--- | --- | ---
decodedString | WString | Decoded string

### Status & Error codes

Code / Value | Identifier / Description
--- | ---
16#0000 | STATUS_NO_ERROR Status: No error
16#7FFD | WARN_UNSUPPORTED_CHAR Warning: Byte stream was decoded but contained unsupported characters
16#7FFE | WARN_STREAM_EXCEEDS_MAX_LEN Warning: Byte stream exceeds max. length of the string at parameter `decodedString`
16#8201 | ERR_START_POS_OUTSIDE Error: Parameter `startPos` is outside array bounds
16#8202 | ERR_COUNT_EXCEEDS_BOUNDS Error: Parameter `count` is outside array bounds
16#8203 | ERR_COUNT_EXCEEDS_MAX_LEN Error: Parameter `count` exceeds max. length of a WString

## Change log

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