---
schema_version: "1"
id: d03f4bda91eae96aa40e20fcdc36c545cfb17d94f7e8aa9e75ec02124062d4c1
title: charCode
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/latest/dw-strings-functions-charcode.md
canonical_url: https://docs.mulesoft.com/dataweave/latest/dw-strings-functions-charcode
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 13400a261abfcc70328f58a4c2ed6463e1fcb8afad7f0a9aa5eb56163f7902dd
description: MuleSoft Documentation Site
release: "2.13"
latest: true
---
---
product: DataWeave
version: 2.13
is-latest-version: true
---

# charCode

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

## charCode(text: String): Number

Returns the Unicode for the first character in an input string.

For an empty string, the function fails and returns `Unexpected empty string`.

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>text</code></p></td><td><p>The input string.</p></td></tr></tbody></table>

### Example

This example returns Unicode for the "M" in "Mule".

#### Source

```DataWeave
%dw 2.0
import * from dw::core::Strings
output application/json
---
{
  "charCode" : charCode("Mule")
}
```

#### Output

```XML
{ "charCode" : 77 }
```

## charCode(text: Null): Null

Helper function that enables `charCode` to work with a `null` value.

_Introduced in DataWeave version 2.4.0._
