Contact

LENB Function (LibreOffice Calc)

Text Beginner LibreOffice Calc

Learn the LENB function in LibreOffice Calc: Calculates length of a text string, with DBCS.

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

Validation scope: References to observed, native-tested, or executed results below describe the saved LibreOffice Calc 25.2.3.2 Linux test evidence dated 12 October 2026. On 13 October, its script and artifact hashes, all 86 ODS/JSON case pairs, and the current official function documentation were checked; CJK/ASCII worked examples were independently reasoned through. Calc was not rerun for this review. Historical observations do not certify other versions, platforms, locales, or workbook imports.

LENB measures text length using LibreOffice Calc’s double-byte character set (DBCS) conventions. A common use is checking a value against a legacy field-width limit that treats many East Asian characters as two units instead of one. It is not a general-purpose UTF-8 byte counter.

What LENB does—and when LEN is better

LENB reports DBCS-style byte length. LEN reports character length. The difference matters for strings containing characters treated as double-byte in Calc’s compatibility rules. For a straightforward character limit such as “no more than 25 visible letters”, start with LEN, not LENB. For a byte-constrained export, confirm the external system’s actual encoding first; LENB is not a reliable substitute for UTF-8 encoding and counting its bytes. [LO-LENB] [LO-LEN] [NATIVE]

Input text =LEN(text) =LENB(text) Interpretation
office 6 6 Six single-byte Latin letters.
中国 2 4 Two CJK characters use two DBCS units apiece.
A中B 3 4 Two Latin letters and one CJK character.
Empty text "" 0 0 No text.

Results above are from official Calc examples and/or independently calculated DBCS arithmetic, with the formulas executed in Calc 25.2.3.2. [LO-LENB] [NATIVE]

Syntax and arguments

=LENB(Text)
Argument Required Type and meaning Omission/default
Text Yes A literal string, a reference to a cell, or an expression Calc can convert to text. No optional default; omitting it is an error.

The English Calc function name is LENB. It has exactly one required argument; there is no byte-mode option or extra encoding parameter. The official Help records availability since LibreOffice 4.2. [LO-LENB]

Locale and OpenDocument names. In the examples, English function names and the normal Calc semicolon argument separator are used. LENB has only one argument, so it needs no separator itself; nested functions such as IF use ;. Calc can show localized function names and configurable separators under Tools → Options → LibreOffice Calc → Formula; select English function names if a translated name is confusing. Do not assume that an Excel comma-separated formula can be pasted unchanged. The supported Calc name here is LENB, not a separately verified ODF alias. [LO-OPTIONS]

Try it: fixed values first

Paste these formulas into blank cells. The right column is the observed result in native Calc 25.2.3.2, not a simulated result.

Formula Result What it demonstrates
=LENB("中") 2 One DBCS character.
=LENB("中国") 4 Two DBCS characters.
=LENB("office") 6 Ordinary Latin text.
=LENB("Good Afternoon") 14 Embedded space counts.
=LENB("A中B") 4 Mixed text.
=LENB(12345.67) 8 The displayed numeric value is coerced to text in this setup.
=LENB("") 0 An empty string.

Calc computes formulas from values, not from cell formatting. A formatted date or currency cell may produce a result different from the on-screen display because type-to-text conversion and locale settings matter. For a specific presentation format, use TEXT explicitly and check the result. This last recommendation is an explanatory inference from value conversion; it was not separately native-tested for date formatting in the saved test. [LO-LENB] [NATIVE]

A repeatable cell-reference example

Enter the literal text 中A in J2. Enter =LENB(J2) elsewhere: the tested answer is 3. For a three-unit legacy field, use:

=IF(LENB(J2)<=3;"Fits";"Too long")

Observed in Calc 25.2.3.2: Fits. Replace the literal 3 with the actual legacy field-width rule. This is useful only when the receiving system counts length using equivalent DBCS conventions; an external application requiring UTF-8 bytes needs an encoding-aware validator instead. [NATIVE]

Advanced patterns and limitations

Combine with string extraction

=LENB(LEFTB("中国";2)) returned 2; =LENB(RIGHTB("中国";2)) also returned 2. These are actual native-tested nested formulas. The related functions LEFTB and RIGHTB replace incomplete DBCS boundaries with spaces instead of returning invalid half-characters. A length check after extraction therefore measures the resulting string, including any replacement space, not the number of original bytes copied. [LO-LEFTB] [LO-RIGHTB] [NATIVE]

Unicode composition is important

Calc 25.2.3.2 returned 1 for =LENB("é"), but 2 for =LENB("e"&UNICHAR(769)) (letter e plus combining acute accent). The visible text may look the same. It returned 4 for =LENB("🙂") in this tested build. Those are observations for one engine, not a promise of how every Unicode character will be encoded or how many UTF-8 bytes it occupies. If your target system has a strict encoding limit, verify using that system’s encoder rather than treating LENB as a universal size measurement. [NATIVE]

Compare bytes and characters carefully

=LENB("中国")-LEN("中国") returned 2 in native testing. This difference is useful as a quick demonstration of DBCS accounting, but it is not a reliable count of East Asian glyphs in arbitrary mixed Unicode text (combining sequences and supplementary characters complicate the comparison). [NATIVE]

Errors and troubleshooting

Symptom or formula Native Calc 25.2.3.2 observation Suggested action
=LENB() Err:518 Supply the required text expression.
=LENB("x";2) Err:509 Remove the extra argument. LENB accepts one.
=LENB(1/0) #DIV/0! Fix the upstream calculation first.
CJK text appears to count twice Expected under DBCS rules. Use LEN for character counts, not LENB.
Results differ from encoded file size DBCS accounting is not the same as the file’s encoding. Validate with the actual import/export system.
A formula name is not recognized English function names may be disabled in localized Calc. Review Formula settings; check the target version supports LENB.

Error labels and codes above are native observations for the tested version and may display differently in other locales or releases. [NATIVE] [LO-OPTIONS]

Compatibility: Calc, Excel, and Google Sheets

LibreOffice Calc documents LENB beginning with version 4.2. Google Sheets independently documents a LENB byte-length function. Microsoft Excel’s current LEN documentation marks LENB as deprecated. Those official documents establish names and broad scope, not identical results for unusual Unicode strings, DBCS locales, or Excel compatibility modes. Only LibreOffice Calc was executed for this guide; Google Sheets and Microsoft Excel were checked against vendor documentation, not run. [LO-LENB] [GOOGLE-LENB] [MS-LEN]

See LEN for character counts, LEFTB and RIGHTB for DBCS-width extraction, or MIDB for extraction from a byte-positioned segment.

Official sources and claim-level evidence

All links accessed 2026-10-12. Source help version is LibreOffice 26.8 Help; native observations were generated in Calc 25.2.3.2 on Linux.

  • [LO-LENB] LibreOffice Calc, LENB official Help: availability since 4.2, purpose, syntax, CJK/ASCII and numeric examples.
  • [LO-LEN] LibreOffice Calc, LEN official Help: character-count comparison.
  • [LO-LEFTB] LibreOffice Calc, LEFTB official Help: incomplete DBCS characters become spaces.
  • [LO-RIGHTB] LibreOffice Calc, RIGHTB official Help: suffix extraction and incomplete characters.
  • [LO-OPTIONS] LibreOffice, Calc Formula Options: localized names and separators.
  • [GOOGLE-LENB] Google, LENB documentation: its separate Sheets syntax; documentation-only check.
  • [MS-LEN] Microsoft, Excel LEN documentation: LENB deprecation notice; documentation-only check.
  • [NATIVE] Saved LibreOffice Calc 25.2.3.2 Linux test records dated 2026-10-12. The preserved script, ODS cached results, and per-formula results agree for the cited cases. This review did not rerun Calc.