Contact

MIDB in Collabora Office Calc: Extract a Byte-Positioned Text Field

Text Intermediate Collabora Office Calc

Extract mixed-width fields with MIDB, including one-based byte positions, partial-character spaces and safe boundary checks.

Verification status: See the evidence and test scope described in this guide. How formula examples are checked

Quick answer: =MIDB("A東京7";2;4) is expected to return 東京. Start is a one-based byte-weighted position, and the last argument is the byte-weighted length to extract.

Syntax and arguments

=MIDB(Text; Start; Number_bytes)

Text is the source string. Start must be at least 1. Number_bytes is a nonnegative extraction count; zero produces empty text. All three arguments are required. Use integer positions and lengths. 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: extract at known boundaries

Put A東京7 in A2. A occupies position 1, 東 occupies 2–3, 京 occupies 4–5, and 7 occupies 6.

Formula Expected text Explanation
=MIDB(A2;2;4) 東京 both complete double-weight characters
=MIDB(A2;2;2) 東 one complete character
=MIDB(A2;4;3) 京7 a complete character and final digit
=MIDB(A2;6;8) 7 stop at the end, without padding
=MIDB(A2;7;2) empty string start beyond available text
=MIDB(A2;1;0) empty string zero count

Example 2: understand partial-character positions

=MIDB("A東京7";3;2) is expected to return two spaces. Position 3 is the second half of 東 and position 4 is the first half of 京. Each incomplete character fragment is represented by one ordinary space.

=MIDB("A東京7";3;3) returns 京, with a leading space. =MIDB("A東京7";2;3) returns 東 , with a trailing space. These are intentional compatibility results, not font-rendering glitches. The exact delimiter check ="["&MIDB(A2;3;2)&"]" returns brackets with two spaces between them.

Advanced example: parameterize an import field

Keep A東京7 in A2. Enter 2 in B2 as the start and 4 in C2 as the length. Put =MIDB(A2;B2;C2) in D2 and =LENB(D2) in E2. Expected results: 東京 and 4.

Now change B2 to 3 and C2 to 3. D2 becomes 京, while E2 becomes 3. The length check still passes even though the beginning of the field is a replacement space. Therefore a successful width check cannot replace validation that the start and end are genuine character boundaries in the source layout.

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 edge cases

  • Start 0 or a negative start is rejected as an illegal argument. Positions are one-based.
  • Negative Number_bytes is rejected. Zero is valid.
  • A valid start beyond the text returns empty text; an overlong count stops at the available end.
  • Input errors and nonnumeric position expressions need correction upstream. Prefer explicit integer positions over relying on decimal coercion.
  • To extract character-oriented fields use MID. Do not derive a MIDB start by counting visible glyphs or by measuring UTF-8 bytes in another application.

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.

References