LENB Function in OpenOffice Calc
Understand LENB in OpenOffice Calc: DBCS length, mixed-language examples, empty text, whitespace and how it differs from LEN and file bytes.
Verification status: Official release source and independently calculated examples for LENB were reviewed. No new Apache OpenOffice Calc application execution is claimed for this guide; the stated version and example limits still apply. How formula examples are checked
LENB returns a text value’s DBCS length. =LENB("AB東京") returns 6: A and B contribute one unit each; 東 and 京 contribute two each. LEN of the same text returns 4 characters.
Availability and version history
- First introduced: Apache OpenOffice 4.0. The official release notes explicitly list LENB among the new DBCS functions.
- Current status: supported in Apache OpenOffice 4.1.16 desktop Calc, confirmed in the enabled function registry and implementation at the AOO4116-GA release tag.
- Last supported version: no final version or removal date established. “Supported in 4.1.16” is a checked version, not an endpoint.
- Platform and locale: desktop Calc; DBCS and system-language details can affect counting. This guide does not claim every platform or Unicode edge case was executed.
- Test status: Apache OpenOffice native execution has not been performed. The principal mixed-CJK examples were independently reasoned from Apache’s implementation and cross-checked in LibreOfficeDev 26.8.0.0.alpha0 (build 2c87e51eeaa2b413ff4ae097b2705eea1995d8e5). A LibreOffice check is supplementary, not an OpenOffice test.
- Evidence checked: 2026-10-14.
Sources: Apache OpenOffice 4.0 release notes, LENB registry, LENB implementation.
Syntax and arguments
LENB(Text)
| Argument | Required? | Meaning |
|---|---|---|
Text |
Required | Text or a reference to a text cell whose DBCS length is counted. |
These examples use semicolons between arguments and English function names. Enter literal text in double quotes; a cell reference does not need quotes.
Worked example: check a DBCS field-width limit
Enter these values in column A:
| Cell | Text | Expected LEN | Expected LENB |
|---|---|---|---|
| A2 | ABCD | 4 | 4 |
| A3 | 東京 | 2 | 4 |
| A4 | AB東京 | 4 | 6 |
| A5 | 東京AB | 4 | 6 |
Enter =LENB(A2) in B2 and fill it down to B5. The expected results are 4, 4, 6 and 6. To flag values that exceed a five-unit legacy field, enter =IF(LENB(A2)>5;"Too long";"Fits") in C2 and fill down. The expected labels are Fits, Fits, Too long and Too long.
This is a validation rule, not a universal encoding check. Confirm that the receiving system uses the same DBCS counting convention before treating the result as an export limit.
Whitespace and empty text
| Formula | Expected result |
|---|---|
=LENB("") |
0 |
=LENB(" A ") |
3 |
=LENB("東京") |
4 |
=LENB("AB東京") |
6 |
Spaces count. LENB does not trim or clean text. A formula returning empty text has a length of zero; this does not necessarily make that cell equivalent to a truly empty cell for other functions.
Avoid a misleading encoding calculation
For the specific text AB東京, LENB’s result is 6. An independently encoded UTF-8 string occupies 8 bytes: two ASCII bytes plus three bytes for each of the two CJK characters. Neither measure should be substituted for the other. Use an encoding-aware export or validation tool when actual file-byte limits matter.
If the requirement is “at most four characters,” use LEN. If it is an agreed DBCS-width limit, use LENB and verify the convention using sample data in both systems.
Common errors and practical checks
An error in the referenced cell propagates. If a number is coerced to text, do not assume that counting it will reproduce the cell’s formatted display. For stable validation, pass deliberate text values and document the treatment of spaces and leading zeroes.
Before using the result in a lookup or concatenation, compare it with a known small example. Put square brackets around returned text with ="["&B2&"]" when spaces would otherwise be invisible.
Related functions
LEN in OpenOffice Calc uses ordinary character positions. The B-suffixed function is a distinct calculation, not a URL alias for that guide.