🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
Char to int and back
This page was created by Hans.karlsen on 2022-11-22. Last edited by Wikiadmin on 2026-07-29.

You can convert between a Unicode numeric value and its character representation when writing OCL or EAL expressions that work with text codes.

Convert an integer to a character

Use Char.ConvertFromUtf32 to convert an integer Unicode value to its corresponding character.

Char.ConvertFromUtf32(65)

This returns 'A'.

For example, use the value 66 when you need the character 'B':

Char.ConvertFromUtf32(66)

Convert a character to an integer

Use Char.ConvertToUtf32 to obtain the integer value for a character in a string. Provide the string first and the character position second.

Char.ConvertToUtf32('AB', 0)

This returns 65, the value of A.

Character positions are zero-based: the first character is at position 0, the second is at position 1, and so on.

Char.ConvertToUtf32('AB', 1)

This returns 66, the value of B.

Expression Result Use
Char.ConvertFromUtf32(65) 'A' Turn a numeric Unicode value into text.
Char.ConvertToUtf32('AB', 0) 65 Get the value of the first character in a string.
Char.ConvertToUtf32('AB', 1) 66 Get the value of the second character in a string.

Choose the correct conversion

Use these operations only when you need the numeric value of a character or need to construct a character from that value. They are not text-to-number parsing operations.

For example, Char.ConvertToUtf32('7', 0) returns the numeric value assigned to the character 7; it does not parse the text as the number seven. To convert text that represents an integer into an integer value, use strToInt. For conversions between numeric types such as integer, decimal, and double, see Documentation:Number conversions.

See also

[[Category:Attributes and data types [Beginner]]]