Documentation/Calc Functions/LENB

From The Document Foundation Wiki
Jump to navigation Jump to search
Other languages:
English • ‎Nederlands

Function name:





Determines the number of bytes in a supplied text string, including those occupied by space characters.




Returns a non-negative integer that is the number of bytes occupied by the supplied string.


Text is a text string (in quotation marks), a number, or a reference to a cell containing one of those types, whose length in bytes is to be determined.

Additional details:

General information about byte-position functions

Note pin.svg

For convenience, the information in this subsection is repeated on all pages describing Calc’s byte-position functions.

Calc provides several byte-position text functions, which are intended to be used with double-byte character set (DBCS) languages. These functions are FINDB, LEFTB, LENB, MIDB, REPLACEB, RIGHTB, and SEARCHB. Each has an equivalent "ordinary" text function with a similar name but without the final letter "B".

Calc considers double-byte characters to be those characters lying within the following Unicode code blocks:

  • Bopomofo Extended (U+31A0 ... U+31BF)
  • Bopomofo (U+3100 ... U+312F)
  • CJK Compatibility Forms (U+FE30 ... U+FE4F)
  • CJK Compatibility Ideographs Supplement (U+2F800 ... U+2FA1F)
  • CJK Compatibility Ideographs (U+F900 ... U+FAFF)
  • CJK Compatibility (U+3300 ... U+33FF)
  • CJK Radicals Supplement (U+2E80 ... U+2EFF)
  • CJK Strokes (U+31C0 ... U+31EF)
  • CJK Symbols and Punctuation (U+3000 ... U+303F)
  • CJK Unified Ideographs Extension A (U+3400 ... U+4DBF)
  • CJK Unified Ideographs Extension B (U+20000 ... U+2A6DF)
  • CJK Unified Ideographs (U+4E00 ... U+9FFF)
  • Enclosed CJK Letters and Months (U+3200 ... U+32FF)
  • Halfwidth and Fullwidth Forms (U+FF00 ... U+FFEF)
  • Hangul Compatibility Jamo (U+3130 ... U+318F)
  • Hangul Jamo (U+1100 ... U+11FF)
  • Hangul Syllables (U+AC00 ... U+D7AF)
  • High Private Use Surrogates (U+DB80 ... U+DBFF)
  • High Surrogates (U+D800 ... U+DB7F)
  • Hiragana (U+3040 ... U+309F)
  • Ideographic Description Characters (U+2FF0 ... U+2FFF)
  • Kanbun (U+3190 ... U+319F)
  • Kangxi Radicals (U+2F00 ... U+2FDF)
  • Katakana (U+30A0 ... U+30FF)
  • Low Surrogates (U+DC00 ... U+DFFF)
  • Private Use Area (U+E000 ... U+F8FF)
  • Yi Radicals (U+A490 ... U+A4CF)
  • Yi Syllables (U+A000 ... U+A48F)

See Wikipedia's Unicode block page for more information about these blocks.

In addition, code points U+005C and U+20AC are taken to be double-byte characters if the system language is set to Japanese.

As noted in ODF 1.2, byte positions are implementation-dependent and so reliance upon them reduces interoperability.


Formula Description Returns
=LENB("Good afternoon") Here the supplied string comprises 14 single-byte characters and so the function returns 14. 14
=LENB("Good afternoon") Here the supplied string comprises 14 double-byte characters and so the function returns 28. 28
=LENB(D1) where cell D1 contains the number 12345.67. Here the function returns 8. 8
=LENB("12,345.67") Here the function returns 9. Note that in this case the number is passed as a string - LEN reports an error if the quotation marks are omitted because the number includes a comma digit group separator. 9
=LENB("") Here the function returns 0, since the argument is the empty string. 0

Related LibreOffice functions:








ODF standard:

Section 6.7.4, part 2

Equivalent Excel functions: