# encvalue_unichar

This built-in function is used to encode a value argument into a universal charstring.

- The function returns a universal charstring.
- If a template is used as the first parameter in encvalue_unichar(), it has to be resolved to a specific value.
- Type of the first argument has to have an encoding method explicitly set with its atributes.
- The second argument determines the string serialization of the resulting universal charstring. 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 third argument is currently ignored.
- The fourth argument selects the encoding method to use, if the type has multiple encoding methods set.

Related keywords:

- send
- encode
- encvalue
- decvalue
- decvalue_unichar

### encvalue_unichar( value_part [, string_serialization [, encoding_info [, dynamic_encoding]]] ) return universal charstring;

Example 1:

type float MyFloat with { encode "RAW" }

var MyFloat f := 1.1;

var universal charstring ucs := encvalue_unichar(f);

This will store the "RAW" encoded form of the float value 1.1, with UTF-8 serialization, into the universal charstring variable ucs.

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");

This will store the "JSON" encoded form of the record value { num := 3, str := "abc" }, with UTF-8 serialization, into the universal charstring variable ucs.

BNF definition of encvalue_unichar