🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators Default
This page was created by Peter on 2019-11-11. Last edited by Wikiadmin on 2026-07-29.

The Encoding.Default OCL operator converts text to a Blob using the default character encoding of the running .NET implementation; use it when you need the encoded bytes of a string.

Syntax

Encoding.Default.GetBytes(aStringExpression)
Part Meaning
Encoding The static class that provides encoding operations.
Default Uses the default encoding for the running .NET implementation.
GetBytes(...) Converts the supplied string expression to encoded bytes.
Result A Blob, which is a byte array containing the numeric byte values that represent the text.

Example

The following expression encodes the name of the first Customer instance:

Encoding.Default.GetBytes(Customer.allinstances->first.Name)

The expression works as follows:

  1. Customer.allinstances retrieves the Customer instances.
  2. ->first selects the first Customer instance.
  3. .Name gets that customer's name as text.
  4. Encoding.Default.GetBytes(...) translates the characters in the name to their raw byte values.

For example, if the selected customer's name is Anna, the result is a Blob containing the bytes that the current default encoding uses to represent Anna.

Encoding behavior

Encoding.Default uses the default encoding for the environment where the expression runs. That encoding is based on the running .NET implementation's current local encoding. Therefore, the byte values are dependent on that default encoding rather than being fixed by the OCL expression itself.

Use this operator when the receiving operation expects a Blob or byte array. If you need to inspect string size rather than convert text to bytes, see length.

See also