CODE Function (Gnumeric)
Inspect Windows-1252 character codes in Gnumeric with CODE, first-character behavior, non-ASCII examples and empty-text errors.
Verification status: Fresh Gnumeric 1.12.57 source and bounded native engine checks; no GUI. How formula examples are checked
Exact syntax
=CODE(text)
CODE returns the Windows-1252 (CP1252) code of the first character in its one required text argument. It is not a general Unicode code-point function. The official help calls out CP1252 specifically; the term “ANSI code page” sometimes used for it is not the name of an ANSI standard.
The original basic-Latin example is preserved below. CODE(“Apple”) also returns 65 because only the first character is examined, while CODE(“a”) returns 97. The difference is case-sensitive character encoding, not a comparison of the full strings.
Beyond basic Latin
The checked character é returns 233. The euro sign € returns 128 in CP1252; its Unicode scalar value is different. The native round trip =CODE(CHAR(128)) returns 128. These examples establish that the implementation is not simply returning the first UTF-8 byte of a string.
The official help identifies CP1252 positions 129, 141, 143, 144 and 157 as lacking matching characters. Use a Unicode-specific function when the task requires Unicode values, and do not assume every character in a modern text document has a CP1252 representation. Unsupported-character conversion is handled as an error in the inspected source, but such inputs were not part of this bounded native test.
Advanced application: inspect imported prefixes
For imported text identifiers in A2:A20, =CODE(A2) can help distinguish a leading ordinary space, uppercase letter or lowercase letter. Preserve the original identifier alongside the diagnostic result. CODE examines only the first character: equal results do not prove the complete strings match, and an invisible character later in the string will not be detected by this check.
Errors and troubleshooting
The empty-string fixture returns #VALUE!, because it contains no first character. Check for an intentionally empty field before attempting to interpret the result as a character. A visible glyph’s code depends on the requested encoding; a CP1252 code should not be used as a Unicode code point in another system. No malformed UTF-8 or control-byte experiments were executed. The numeric result is an encoding diagnostic, not a locale-independent identifier for every possible character.
Worked example
=CODE("A")
Expected result: 65.
Why it works: Return the numeric code for a basic Latin letter.
Recorded native results
=CODE("A")→ 65=CODE("Apple")→ 65=CODE("a")→ 97=CODE("é")→ 233=CODE("€")→ 128=CODE("")→ #VALUE!=CODE(CHAR(128))→ 128
Availability, portability and verification
Original introduction and last functioning release are not established. The retained historical check documented Gnumeric 1.12.62 registration on 14 October 2026, for desktop installations with the fn-string module included and enabled. This is separate from the fresh official 1.12.57 source inspection and bounded ssconvert execution on 17 October 2026. No execution of 1.12.62 is claimed.
Every saved input formula and output cell was independently read back; results match explicit code-point, table-lookup, Roman-notation or sorted-multiset expectations exactly. Source and native evidence hashes were verified. This is engine evidence, not GUI verification. The earlier comparable LibreOffice Calc 25.2 test is historical context; it does not establish identical coercion or extensions across programs. Check receiving applications and locales before transferring formulas.