# decvalue_unichar

This built-in function decodes a value from a universal charstring and cuts the consumed part from the universal charstring.

- The function return type is integer holding the error code: 0 - decoding was successful, 1 - unspecified cause of decoding failure, 2 - decoding failed because the universal charstring did not contain enough characters.
- Decoded value returned through the second (out) argument.
- Type of the second argument has to have an encoding method explicitly set with its atributes.
- The third argument determines the string serialization of the universal charstring argument. The possible serializations are: UTF-8, UTF-16, UTF-16LE, UTF-16BE, UTF-32, UTF-32LE and UTF-32BE. If the argument is omitted, then UTF-8 serialization is used.
- The fourth argument is currently ignored.
- The fifth argument selects the encoding method to use, if the type has multiple encoding methods set.

Related keywords:

- encode
- encvalue
- encvalue_unichar
- decvalue

### decvalue_unichar( inout bitstring_value, out decoded_value [, in string_serialization [, in encoding_info [, in dynamic_encoding]]] ) return integer;

Example 1:

type float MyFloat with { encode "RAW" }

var MyFloat f := 1.1;

var universal charstring ucs := encvalue_unichar(f);

var integer i := decvalue_unichar(ucs, f);

Example 2:

type record MyRecord {
integer num,
charstring str
}
with {
encode "XML";
encode "JSON";
}

var MyRecord r := { num := 3, str := "abc" };

var universal charstring ucs := encvalue_unichar(r, "UTF-8", "", "JSON");

var integer i := decvalue_unichar(ucs, r, "UTF-8", "", "JSON");

BNF definition of decvalue_unichar