LENB in Collabora Office Calc: Count DBCS-Weighted Text
Count mixed Latin and CJK text with LENB while distinguishing compatibility weights from real encoded byte sizes.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: =LENB("A東京7") is expected to return 6: A and 7 contribute one each, and 東 and 京 contribute two each. Use LENB when a field specification explicitly follows this spreadsheet compatibility rule.
Syntax and argument
=LENB(Text)
Text is the string, cell reference or expression to count. The result is a number. Spaces and punctuation are included. The formulas use English function names and semicolon argument separators. Adapt these to your formula settings; do not type square brackets used to mark optional arguments. Put input data in a source column and formulas in a separate result column so you can inspect both.
Example 1: audit mixed-width values
Enter each value as text in A2:A6 and enter =LENB(A2) in B2, then fill down.
| Source text | Expected LENB | Calculation |
|---|---|---|
| A東京7 | 6 | 1 + 2 + 2 + 1 |
| 東京 | 4 | 2 + 2 |
| AB 7 | 4 | 1 + 1 + 1 + 1 |
| A | 2 | fullwidth block |
| カ | 2 | halfwidth/fullwidth block |
The last row is important: the word “halfwidth” does not guarantee a weight of one in this implementation. For empty text, =LENB("") returns 0.
Example 2: expose trailing spaces
=LENB("A東 ") is expected to return 4, whereas =LENB("A東") returns 3. A trailing ordinary space contributes one. If a source column appears correct but fails a length check, inspect the text between delimiters with ="["&A2&"]"; widening the column does not remove spaces.
Advanced example: validate a compatibility field limit
Suppose A2:A4 contain A東京7, AB12 and 東京大阪. In B2 enter =LENB(A2) and fill down. The expected counts are 6, 4 and 8. In C2 enter =IF(B2<=6;"Fits";"Review") and fill down. Expected labels are Fits, Fits and Review.
This checks only a maximum compatibility count. It does not validate allowed characters, actual export bytes, uniqueness or a minimum length. If the receiving database says “six UTF-8 bytes,” use an encoding-aware validation step instead: 東京 occupies six UTF-8 bytes even though LENB here returns four.
What “bytes” means here
The pinned Collabora implementation assigns a weight of one or two to UTF-16 code units using Unicode blocks. The CJK examples below each have weight two; ordinary Latin letters, digits and spaces have weight one. This is a compatibility counting rule, not a UTF-8 file-size calculator, a count of visible glyphs, or a font-width measurement.
The source applies these block rules regardless of the ordinary Western-language examples. There is a specific system-language exception: backslash (U+005C) and euro (U+20AC) have weight two when the configured system language is Japanese. Otherwise they have weight one. Changing a cell’s number format is not the same as changing the configured system language.
The Halfwidth and Fullwidth Forms block is also weighted two in this implementation, including halfwidth katakana. Do not assume an ASC-converted string necessarily has LENB equal to its visible character count. Supplementary-plane characters use surrogate pairs in UTF-16, and the implementation iterates code units, not grapheme clusters. Avoid B-functions for emoji-safe or combining-mark-safe clipping. Use the ordinary text functions for character-oriented work and test complex Unicode on your actual build. Source: byte weighting and extraction.
Errors and troubleshooting
- LENB has one required argument. Missing or extra arguments are not a way to select an encoding.
- A source error remains an error; check A2 before treating the result as a length failure.
- Pass identifiers as text. Numeric coercion can depend on locale and does not necessarily count the formatted cell display. A date’s visible date format is not a text string unless explicitly converted.
- Ordinary spaces count; so can invisible Unicode marks. LENB is not a whitespace-cleaning function.
- For a character-oriented comparison use LEN. For extracting visible prefixes use LEFT. Avoid assuming that either is a grapheme-cluster counter for all complex text.
Availability and verification
Documented in a Collabora Office 26.04 Help snapshot retrieved October 17, 2026, from the linked latest Help pages, and reviewed October 19, 2026, against the Collabora co-26.04 source commit linked below. Fresh retrieval attempts for the versioned 26.04 Help pages returned HTTP 503, so the documentation evidence is the saved snapshot rather than a successful fresh retrieval. The first release that introduced the function is not established here. Online, mobile and later desktop deployments may differ; confirm function availability and settings in the actual client.
Checked October 19, 2026. The expected answers were independently calculated from documented rules and the pinned implementation. These are not results captured from a running Collabora application; native execution and screenshots were unavailable. No screenshot is presented as evidence.