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

You can use BigEndianUnicode when an OCL expression must convert text to or from a byte array encoded as UTF-16 big-endian; this is for developers working with external data that uses that encoding.

What BigEndianUnicode means

BigEndianUnicode is the UTF-16 big-endian encoding. It represents text as 16-bit code units and stores the most significant byte first.

Use it only when the byte data is known to be UTF-16 big-endian. The encoding is relevant when you convert between a String and a byte array; after decoding, use normal String operators to work with the resulting text.

Convert text to bytes

Use GetBytes(string) to encode a String as a byte array.

Encoding.BigEndianUnicode.GetBytes('Hello')

This expression returns the UTF-16 big-endian byte representation of Hello.

Convert bytes to text

Use GetString(bytearray) to decode a byte array as a String.

Encoding.BigEndianUnicode.GetString(bytearray)

Replace bytearray with the byte-array value that you received. For example, use this conversion before applying a String operation such as ToUpper().

Encoding.BigEndianUnicode.GetString(bytearray).ToUpper()

Choose the matching encoding

The same bytes produce meaningful text only when you decode them with the encoding used to create them. If the source bytes use another encoding, select that encoding instead. Documentation:Encoding describes the available Encoding conversions, including ASCII, Default, Unicode, UTF32, UTF7, and UTF8.

Task Use
Encode a String for a UTF-16 big-endian receiver Encoding.BigEndianUnicode.GetBytes(string)
Decode UTF-16 big-endian bytes received from another system Encoding.BigEndianUnicode.GetString(bytearray)
Count characters after decoding Decode first, then use Size()

See also