Character.ToNumber
TextReturns the Unicode code point number for the given character.
Syntax
Character.ToNumber(character as text) as numberParameters
| Name | Type | Required | Description |
|---|---|---|---|
character | text | Yes | A single-character text value. |
Return Value
number — The numeric Unicode code point of the character.
Remarks
Character.ToNumber returns the Unicode code point (an integer) for the given single character. This is the inverse of Character.FromNumber. The input must be exactly one character long — passing a multi-character string or an empty string raises an error.
The primary use of this function is character classification: you can test whether a character falls within a known Unicode range to determine if it is a digit (48–57), uppercase letter (65–90), lowercase letter (97–122), or a control character (0–31). This approach is faster than converting to a list and filtering when you only need to classify one character at a time.
When processing every character in a string, combine Text.ToList with List.Transform to apply Character.ToNumber across all characters at once. The resulting list of code points can then be filtered or analyzed with standard list functions.
Note that Power Query text comparisons are case-sensitive by default. If you need to classify characters without regard to case, compare against both the uppercase and lowercase ranges, or normalize the character with Text.Upper or Text.Lower first.
Examples
Example 1: Get the code point for a character
Character.ToNumber("A")Result | |
|---|---|
| 1 | 65 |
Example 2: Check whether a character is a digit
let
ch = "7",
code = Character.ToNumber(ch),
isDigit = code >= 48 and code <= 57
in
isDigitThe final output — a logical true, confirming that "7" is a digit character.
Result | |
|---|---|
| 1 | TRUE |
Example 3: Get code points for each character in a string
List.Transform(Text.ToList("E001"), Character.ToNumber)Result | |
|---|---|
| 1 | 69,48,48,49 |