> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.itential.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.itential.com/_mcp/server.

# charCodeAt

> Use the charCodeAt task to obtain the Unicode decimal (UTF-16) value for a character at a specific position in a string.

The `charCodeAt` task obtains a Unicode decimal value (UTF-16) for a character at a specific position in a string. UTF-16 is a 16-bit integer between 0 and 65535.

## Potential use cases

This task is a character-processing method that returns an encoded value at a specific location, rather than the character itself. You could use `charCodeAt` to perform string handling with characters you cannot type directly using a keyboard.

This task is also useful for working with strings used in objects such as a Text Field, Context Menu, or File Reference object. For example, if you have an input form with a text field that requires an email address, you could use `charCodeAt` to build a text validation function in the form control to parse the email address character by character and validate whether the entry is formatted correctly.

## Properties

| Incoming | Type   | Description                                                                                                                                                                                                                  |
| -------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `str`    | String | Required. The string to get the character code from.                                                                                                                                                                         |
| `index`  | Number | Required. The position of the character in `str` that you want to return the Unicode value for. An index of the first character is `0`, the second character `1`, and so on. If `index` is not a number, it defaults to `0`. |

| Outgoing | Type   | Description                                                                                                                                              |
| -------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `code`   | Number | The UTF-16 decimal value that is returned. The task returns `NaN` if there is no character at the specified `index`, or if the `index` is less than `0`. |

## Examples

### Example 1

In this example:

* The reference variable for the incoming `str` is statically set to `Hello World!`.
* The `index` number is `4`.

![](/_fern-img/afbb9489d0eda14e2ce6e5b204568a8e0e5c989e5f2346cc4913e9482a989c00.webp)

Once the workflow is executed, the `code` value is displayed under the **Outgoing** tab in **Task History**, accessed from **Jobs** in Operations Manager. The character code `111` is equal to the lowercase letter `"o"`.

![](/_fern-img/3f70df643e67520faa68a5a49af499586e6176e133f227ad92a3e1d132a217c9.webp)

### Example 2

In this example:

* The reference variable for the incoming `str` is statically set to `Hello Krunal Legere`.
* The `index` number is `5`.

![](/_fern-img/2b9ef8475eb8f693a54419a5d1547682e117a810f459bae03ad49253b345152e.webp)

The character code that returns is `32`, which is equal to a space in the string.

![](/_fern-img/b73a7d5c4447c2f99d0ebf040bdb23b841bcb1238ae66edb02ecf83558f504a0.webp)