LEFTB in Collabora Office Calc: Extract a Byte-Weighted Prefix
Use LEFTB for DBCS-weighted text extraction, with mixed text, boundary spaces, count limits and Unicode cautions.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: =LEFTB("A東京7";3) is expected to return A東. LEFTB takes text from the start, using Collabora’s byte-weighted compatibility count. Choose LEFT instead when the field specification counts characters.
Syntax and arguments
=LEFTB(Text [; Number_bytes])
Text is the source string or cell reference. Number_bytes is an optional nonnegative count. Omitted count means one byte-weighted unit, not necessarily a complete visible character. A count of zero returns the empty string. Use integer counts for predictable field boundaries. 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: map a mixed-width field
Put A東京7 in A2. Its byte-weighted positions are A at 1, 東 at 2–3, 京 at 4–5, and 7 at 6. Enter these formulas in separate cells:
| Formula | Expected text |
|---|---|
=LEFTB(A2;0) |
empty string |
=LEFTB(A2;1) |
A |
=LEFTB(A2;2) |
A |
=LEFTB(A2;3) |
A東 |
=LEFTB(A2;4) |
A東 |
=LEFTB(A2;6) |
A東京7 |
=LEFTB(A2;20) |
A東京7 |
Spaces inside backticks are real returned spaces. A request ending inside a double-weight character cannot return half of that character; the implementation substitutes one ordinary space. It does not silently move the boundary to preserve a whole character.
Example 2: compare omitted count with an explicit count
=LEFTB("東京") is expected to return one space. =LEFTB("東京";2) returns 東. This distinction matters when an imported field sometimes starts with Latin letters and sometimes with Japanese text. For ordinary Latin input, =LEFTB("INV-42";3) returns INV.
Advanced example: inspect a fixed-width extraction
Put A東京7 in A2 and 4 in B2. In C2 enter =LEFTB(A2;B2). The expected result is A東 . In D2 enter =LENB(C2), which is expected to return 4: one Latin character, one complete double-weight character and one replacement space.
This is a useful boundary audit for a legacy import, but a matching LENB alone does not prove the extracted text is a valid identifier. Keep the original string and inspect any field that can end inside a double-weight character. Do not trim replacement spaces automatically if the target field is fixed-width.
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 practical limits
- A negative count is rejected as an illegal argument. Check a calculated field width before applying it.
- A count longer than the available text returns all the text; it does not pad the result to the requested size.
- Empty text returns empty text for nonnegative counts.
- Text in a count cell, an input error, or missing required text can prevent evaluation. Use a numeric integer count and inspect the source formula first.
- Different visible spacing in a proportional font is not evidence of a counting error. Put results between delimiters, for example
="["&LEFTB(A2;2)&"]", to reveal the replacement space.
Review LEN when you need character-oriented lengths. These B-functions do not establish the byte size of a CSV export or validate its encoding.
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.