🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators UTF32
This page was created by Lars.olofsson on 2023-05-03. Last edited by Wikiadmin on 2026-07-29.

You can use UTF32 in OCL when you need to encode a string as UTF-32 bytes or decode UTF-32 bytes into a string through the .NET Encoding class.

Use UTF32 in OCL

UTF-32 (Unicode Transformation Format, 32-bit) represents each Unicode code point with 32 bits, or four bytes. In MDriven OCL, access this encoding as Encoding.UTF32.

Use GetBytes to convert text to a byte array, and GetString to convert a byte array to text.

Task OCL expression Result
Encode text as UTF-32 Encoding.UTF32.GetBytes('Hello') A byte array containing the UTF-32 representation of Hello.
Decode UTF-32 bytes Encoding.UTF32.GetString(bytearray) A string decoded from bytearray as UTF-32.

Encode a string

Use GetBytes(string) when the receiving system expects UTF-32 data.

Encoding.UTF32.GetBytes('Hello')

UTF-32 uses four bytes for each Unicode code point. For example, five ASCII letters require 20 bytes when encoded as UTF-32.

Decode a byte array

Use GetString(bytearray) only when the byte array contains UTF-32 encoded data.

Encoding.UTF32.GetString(bytearray)

The encoding used to decode bytes must match the encoding used to create them. For example, decode bytes produced by Encoding.UTF32.GetBytes('Hello') with Encoding.UTF32.GetString(...), not with an ASCII or default encoding.

When to use UTF32

Choose UTF-32 when an external format or integration explicitly requires UTF-32. Its fixed four-byte representation can make each Unicode code point occupy a predictable amount of storage, but it uses more space than variable-length encodings for ordinary text.

For the available encodings and the general GetBytes and GetString pattern, see Documentation:Encoding.

See also