LENB
Returns the number of bytes used to represent the characters in a text string. Each double-byte character (DBCS, used in Japanese, Chinese, Korean) counts as 2; each single-byte character counts as 1.
LENB(text)Arguments
textThe text whose byte length you want to measure. Spaces count as characters.
=LENB("Excel")5 single-byte characters = 5 bytes
=LENB("日本")Each double-byte character counts as 2 bytes
=LENB("AB日")2 single-byte + 1 double-byte = 4 bytes
- •On systems without DBCS language support, LENB returns the same as LEN
- •Use LEN to count characters regardless of byte width
- •Mainly relevant when handling East Asian text
- •Helpful when validating data length against database byte limits
- •Assuming LENB always returns the same result as LEN - they only match when the text contains no double-byte characters, and diverge as soon as Japanese, Chinese, or Korean characters are present
- •Using LENB to count characters for display or layout purposes when LEN (which counts characters, not bytes) is actually what's needed
- •Forgetting that spaces and punctuation count as single-byte characters just like Latin letters, so a string mixing scripts needs careful byte accounting rather than a simple assumption
LENCounts characters regardless of byte width, giving a different (usually smaller) result than LENB whenever double-byte characters are present.LEFTBExtracts a substring based on byte count, using the same byte-counting logic that LENB measures.MIDBExtracts a substring starting at a specific byte position, relying on the same double-byte-aware counting as LENB.Why does LENB give a different result than LEN for the same text?
LENB counts bytes, and double-byte characters (common in Japanese, Chinese, and Korean text) count as 2 bytes each, while LEN always counts them as a single character. The two only match when text contains exclusively single-byte characters.
When would I actually need LENB instead of LEN?
When validating text length against a byte-based limit, like a database field or a legacy system that measures storage by bytes rather than character count.
What happens if my system doesn't support double-byte character sets?
LENB behaves identically to LEN in that case, since there are no double-byte characters for it to count differently.
Need to translate a formula using LENB?
Use our translator to convert your complete formula
