Documentation/Calc Functions/LEFTB/en

Function name:
LEFTB

Category:
Text

Summary:
Extracts a sub-string from the left of the supplied text string, with the length of the sub-string specified in bytes.

Syntax:
LEFTB(Text[; Number of Bytes])

Returns:
Returns a text string comprising the specified number of bytes from the left side of the supplied text string.

Arguments:
Text is a text string (in quotation marks), a number, or a reference to a cell containing one of those types, that is the string from which characters are to be extracted.

Number of Bytes is a non-negative integer, or a reference to a cell containing a non-negative integer, that is the number of bytes to be extracted. If Number of Bytes is omitted, LEFTB uses the value 1.


 * If Number of Bytes is non-numeric, then LEFTB reports a #VALUE! error.
 * If Number of Bytes is a non-integer value, LEFTB truncates it to an integer value.
 * If Number of Bytes is less than 0, then LEFTB reports an invalid argument error (Err:502).
 * If Text comprises fewer bytes than the value of Number of Bytes, LEFTB returns a copy of Text.

Details specific to LEFTB function
If the specified number of bytes would otherwise lead to extracting only one byte of a two-byte character, LEFTB instead inserts a space character (Unicode U+0020) at the end of the returned string.

Examples:
The following examples are similar to those used for the LEFT function and demonstrate the consistent behavior of the two functions for single-byte character strings.

The remaining examples demonstrate the behavior of LEFTB for strings that include double-byte characters. These examples utilize the double-byte characters "中" (Unicode CJK Unified Ideograph-4E2D) and "国" (CJK Unified Ideograph-56FD).

Related LibreOffice functions:
FINDB

LEFT

LENB

MIDB

REPLACEB

RIGHTB

SEARCHB

ODF standard:
Section 6.7.3, part 2

Equivalent Excel functions:
LEFTB