Contact

UNICODE Function (Gnumeric)

Text Beginner Gnumeric

Learn the UNICODE function in Gnumeric: Returns the numeric code for the first Unicode character in a text string.

Verification status: Official documentation referenced; example outcomes independently reasoned or arithmetically checked where stated. Not executed in Gnumeric. How formula examples are checked

Validation limits: Examples were independently checked against character encodings and the checksum-verified official Gnumeric 1.12.62 source. No native Gnumeric execution or screenshots were performed.

What UNICODE does

UNICODE returns the numeric Unicode code point of the first character in a text value. It is particularly useful for diagnosing look-alike characters, checking the leading character of an imported identifier, or confirming that a code-point-to-character conversion used the intended symbol. The tagged Gnumeric code retrieves the string argument and returns its first UTF-8 character via g_utf8_get_char; an empty string is handled as #VALUE!. Evidence: Gnumeric 1.12.62 help_unicode and gnumeric_unicode implementation.

UNICODE is not the same function as CODE: the latter uses CP1252 (Windows-1252), which cannot represent the entire Unicode repertoire. Evidence: tagged help_code and gnumeric_code.

Exact syntax and parameters

=UNICODE(c)
Parameter Required? Gnumeric meaning
c Yes Text/string value; the code point of its first Unicode character is returned. A multiple-character input is not summed or encoded as a whole.

The tagged upstream implementation registers unicode with a one-string-argument signature ("S"); there is no documented default. For a single nonempty valid UTF-8 text string, the return is a numeric scalar value. Evidence: Gnumeric 1.12.62 source function registration and implementation.

Version and locale: This guide targets upstream Gnumeric 1.12.62, not an independently installed desktop build. Examples use English function identifiers and text literals between quotation marks. The direct UNICODE formula has one argument so its examples do not depend on the locale’s function-argument separator; nested examples that use other functions should be adapted if the worksheet locale uses semicolons rather than commas. Unicode character values themselves should not be confused with localized text sorting/collation. Evidence: official 1.12 release source; Gnumeric function catalogue.

Example 1 — Read Unicode code points from text

Enter the following text values in A2:A6 and enter =UNICODE(A2) in cell B2, then fill down. Outputs are expected results from independent Unicode calculation, not observed Gnumeric values:

Row A (text) B (formula) Expected numeric output Explanation
2 A =UNICODE(A2) 65 Latin uppercase A
3 π =UNICODE(A3) 960 Greek small pi
4 € =UNICODE(A4) 8364 Euro sign
5 ★ =UNICODE(A5) 9733 Black star
6 😀 =UNICODE(A6) 128512 Grinning face

How the results were checked: Python ord on the first character of each string yields the expected integer, while the Gnumeric gnumeric_unicode source calls GLib’s g_utf8_get_char. The tagged official help gives =UNICODE("A") as an example. No native application result was captured. Evidence: tagged Gnumeric implementation.

Example 2 — Detect a hidden leading space in an imported identifier

Suppose an imported text field is supposed to start with a capital A:

Cell Input text Formula Expected result
A2 Apple =UNICODE(A2) 65
A3 Apple (one leading space) =UNICODE(A3) 32

The whitespace difference can be hard to notice visually. UNICODE reads the first code point, so the leading ASCII space yields 32. This is an independently calculated expected result and source-checked function behavior, not a native Gnumeric worksheet observation. Evidence: official source’s first-code-point implementation.

The function is for diagnosis: it does not remove the space. Use a suitable text-cleaning formula after determining the cause, and verify that your data model permits removal of leading whitespace.

Advanced example — Unicode round trip and first-character semantics

For numeric Unicode code point 960 in A2:

=UNICODE(UNICHAR(A2))

Expected result: 960, because UNICHAR(960) produces π and UNICODE("π") returns 960. The result is independently checked via ord(chr(960)) and supported by the two official implementations. The special code point U+0000 is deliberately not covered by this guarantee because native string/NUL handling has not been verified. Evidence: tagged gnumeric_unichar and gnumeric_unicode.

To examine the leading character only, compare these one-argument formulas:

Formula Expected output Why
=UNICODE("AB") 65 Only the first A counts.
=UNICODE(" π") 32 The first character is a space, not pi.
=UNICODE("Ï€A") 960 The first character is Greek pi.

Combined characters: Some visually single glyphs consist of more than one Unicode code point (a base letter plus a combining mark). UNICODE returns the first code point, not necessarily an entire grapheme cluster. The code uses g_utf8_get_char, not a grapheme-segmentation engine. Evidence: tagged source.

Errors, limits, and troubleshooting

Situation Expected/source-based behavior What to check
=UNICODE("") #VALUE! (the implementation explicitly rejects an empty string) Confirm the referenced cell contains text before invoking the function.
=UNICODE("AÏ€") 65, not a combination of both characters To inspect later characters, extract a substring first using a separately documented function.
A leading space produces 32 This is valid data, not a function error Inspect whitespace in the source cell.
A pictograph is displayed as an empty box Font/rendering may be missing Verify code point and test a font with glyph coverage.
A formula refers to an error-bearing cell No native behavior established for this workbook/input path Diagnose the original cell error instead of assuming specific propagation.
Visually identical inputs produce different numbers Unicode may have multiple sequences for visually similar text Check normalization and each code point rather than assuming one displayed glyph means one encoded scalar.

The #VALUE! for an empty string follows the tagged Gnumeric implementation’s value_new_error_VALUE branch; not a test observed in the installed application. Inputs that are not ordinary strings, locale-specific coercions, and malformed imported encodings need native validation; the guide does not invent their outcomes. Evidence: tagged gnumeric_unicode.

Compatibility and Gnumeric-specific cautions

The official tagged Gnumeric help labels UNICODE Excel-compatible. That is useful for planning common code-point lookups, but not evidence of identical behavior for malformed text, error propagation, Unicode normalization, or NUL-containing strings across applications. The official public Gnumeric catalogue registers the function; the tagged source labels its implementation complete with basic project tests, neither of which proves that these example sheets were executed during this review. Evidence: official help and registry; catalogue.

Do not substitute CODE for Unicode code points: the tagged source explicitly describes CODE as operating on Windows-1252 (CP1252) characters. A code for π or 😀 must be handled as Unicode, not as an 8-bit CP1252 character. Evidence: help_code, gnumeric_code.

  • UNICHAR converts a numeric Unicode scalar into a character; use it for a round-trip check.
  • CODE returns a CP1252 character code; it does not cover all Unicode.
  • CHAR maps a CP1252 code number to a character.
  • LEFT can isolate the leftmost text character for another diagnostic formula, subject to that function’s own documented behavior.

Primary source verification: The official Gnumeric 1.12.62 archive was verified against GNOME’s SHA-256 checksum, then plugins/fn-string/functions.c was inspected without compilation or execution.

Official sources and validation statement

Official software/version: Tagged upstream Gnumeric 1.12.62. References accessed: 2026-10-12 UTC.

  1. Gnumeric official 1.12.62 tagged source (help_unicode, gnumeric_unicode, registration; plus related functions). Supports exact syntax, first-code-point semantics, empty-input error branch, registration, and documentation-level compatibility.
  2. Official Gnumeric function catalogue. Supports catalogue presence and listed implementation/testing status, not native execution here.
  3. GNOME 1.12 source directory. Identifies the release family/version context.
  4. GLib Unicode validator. Background for scalar validity in the inverse UNICHAR function, including special handling of U+0000.

Validation: Official manual and checksum-verified release-source inspection; independent code-point, encoding and string calculations. Native Gnumeric execution, screenshots, locale/platform and workbook round-trip tests were not performed.