Text functions
CHAR
Matches all 145 recorded answers
Recorded: 145 workbook cells. How we measure this · See the Rust code
Local names in 40 languages
| Language | Name in Excel |
|---|---|
| Arabic | CHAR |
| Bulgarian | CHAR |
| Czech | CHAR |
| Danish | TEGN |
| German | CHAR |
| Greek | CHAR |
| English (Australia) | CHAR |
| English (United Kingdom) | CHAR |
| English (United States) | CHAR |
| Spanish | CARÁCTER |
| Estonian | CHAR |
| Finnish | CHAR |
| French | CHAR |
| Hebrew | CHAR |
| Croatian | CHAR |
| Hungarian | CHAR |
| Indonesian | CHAR |
| Italian | CODICE.CARATT |
| Japanese | CHAR |
| Korean | CHAR |
| Lithuanian | CHAR |
| Latvian | CHAR |
| Norwegian | CHAR |
| Dutch | TEKEN |
| Polish | CHAR |
| Portuguese (Brazil) | CHAR |
| Portuguese (Portugal) | CHAR |
| Romanian | CHAR |
| Russian | СИМВОЛ |
| Slovak | CHAR |
| Slovenian | CHAR |
| Serbian (Latin) | CHAR |
| Swedish | CHAR |
| Thai | CHAR |
| Turkish | DAMGA |
| Ukrainian | CHAR |
| Vietnamese | CHAR |
| Chinese (Simplified) | CHAR |
| Chinese (Hong Kong) | CHAR |
| Chinese (Traditional) | CHAR |
Names from Microsoft's support site.
What it does
CHAR(number)
CHAR maps a small integer to the single character that the integer designates in some
character set, and returns that character as a one-character text value. The whole content of
the function is the question "which character set?", and the answer is not a mathematical
constant: Microsoft's article states that the character returned comes from the character set
used by your computer, and names two — the ANSI character set on Windows, the Macintosh
character set on Macintosh.
So the function is best read as a two-step composition, not a one-step map:
- the argument is truncated to an integer and checked against the admissible range 1–255;
- that integer is interpreted as an index into a host-dependent single-byte character set, and
the resulting character is delivered as
Text— which, in the Handbook's value model, is a sequence of UTF-16 code units (see the value universe).
Step 2 is where implementations can legitimately differ, because the two steps only agree trivially on the ASCII subrange 32–126, where every candidate encoding coincides. Above 127 the identity "code number 128 means the character U+0080" and the identity "code number 128 means the Windows-1252 character €" are different functions, and the argument range 1–255 spans both.
Arguments
number — required, the code number. Microsoft's article states it as a number between 1 and
255 specifying which character you want. The argument is numeric, so the ordinary to-number
coercion of chapter 02 applies: a logical, or text that
reads as a number, converts before the range check.
There is no second argument and no encoding selector. A formula that needs a specific encoding
cannot express it through CHAR; that is the reason UNICHAR exists.
Try it
Quirks
Result and edge cases
The return kind is Text, always exactly one character long when the call succeeds.
Two boundaries are specific enough to state:
- Non-integer arguments. The admissible range is documented as a range of numbers, not of integers, so some truncation or rounding rule must exist. Which one Excel applies — truncation toward zero, floor, or round-half-away — is not stated in Microsoft's article and has not been checked here.
- Excel for the web. Microsoft's article carries an explicit platform restriction: on Excel
for the web only
CHAR(9),CHAR(10),CHAR(13)andCHAR(32)and above are supported. This is a documented per-surface difference, not a quirk of one build, and any implementation claiming to match "Excel" must say which Excel.
Array arguments, empty cells and omitted arguments follow the shared call model; nothing about
CHAR overrides it.
Errors
Error inputs propagate rather than convert, per the universal rule in chapter 02.
How to implement
Notes for implementers
The interesting decision is the 128–159 window. In Windows-1252 (the encoding usually meant by
"ANSI" on a Western Windows install) that window holds printable characters — the euro sign,
curly quotes, the en and em dashes — mapped to Unicode code points scattered far outside
128–159. In a "code unit equals code number" implementation the same window holds the C1
control characters. A program that treats CHAR as chr() over UTF-16 code units and one that
treats it as a Windows-1252 decode agree everywhere except here, and disagree visibly on the
most commonly typed non-ASCII characters in English text.
A second decision follows from the first: "the ANSI character set" is not one encoding. The system ANSI code page differs by Windows locale (1252, 1251, 1250, 932, …), so a faithful host-dependent implementation is locale-sensitive in a way the function's axis chips do not currently record.
Rust code
Show the CalcFunc source of this function
Quoted from the public repository DnaCalc/DnaCalc, crates calc-func and calc-fml, at commit 9e1884369a67. Comments are the source's own. A kernel shared with other functions appears once, on its module page.
CHAR · 4 lines · calc-func/src/catalogue/text_functions.rs on GitHub1 char_fn "CHAR" (1, 1) [V "number"] |s, a, sv| {
let n = num(s, a, 0)?;
out_text(k::char_from_number(n))
}
char_from_number · 14 lines · calc-func/src/ported/text_kernels.rs on GitHub/// CHAR: the character with code `n` (truncated) of code page 1252, 1 to 255.
pub(crate) fn char_from_number(n: f64) -> Result<ExcelText, WorksheetErrorCode> {
let n = n.trunc();
if !(1.0..=255.0).contains(&n) {
return Err(WorksheetErrorCode::Value);
}
let code = n as u16;
let unit = if (0x80..=0x9F).contains(&code) {
CP1252_HIGH[usize::from(code - 0x80)]
} else {
code
};
Ok(ExcelText::from_utf16_code_units(vec![unit]))
}
Argument and result plumbing
No implementation has been published with a Handbook test suite for this function.
Version differences
No comparison between specific Excel builds is recorded here yet. This does not establish that all builds behave alike.
Alternatives
Relationships
CODEis the inverse direction — character to number — and shares the same host-character-set dependency and therefore the same open question.UNICHARandUNICODEare the Unicode-explicit pair. They are the functions to reach for when the code point matters and the host must not:UNICHARtakes a Unicode code point rather than a byte-sized index.CHARis not deprecated in favour of them; both pairs are live.- Readers routinely reach for
CHAR(10)to embed a line break in a formula-built string, and forCHAR(34)to embed a double quote. Neither use is a special case in the function; they are just the two control characters that formula text cannot easily carry literally.
Named variants
No named variants are recorded yet.
Suggest a correction or contribute an implementation · For agents