The LENB function in Google Sheets returns the length of a string measured in bytes rather than characters, which matters when working with double-byte character sets like Japanese, Chinese, or Korean text. Dive into our comprehensive guide to see how it differs from the standard LEN function.
Parameters
string: The text or cell reference whose byte length you want to measure.
Step-by-Step Tutorial
-
Measuring the byte length of standard text:
- Example:
=LENB("Hello") - Result:
5(each character is a single byte)
- Example:
-
Measuring the byte length of double-byte text:
- Example:
=LENB("こんにちは") - Result:
10(each double-byte character counts as 2 bytes, unlikeLENwhich would return5)
- Example:
Use Cases and Scenarios
- Multilingual Data Processing: Accurately measure text length for languages that use double-byte character sets.
- Field Length Validation: Enforce byte-based limits required by legacy systems or database fields.
- Text Encoding Analysis: Compare
LENandLENBresults to detect the presence of double-byte characters in a dataset.
Related Functions
LEN: Returns the length of a string in characters.LEFTB: Returns the left portion of a string up to a certain number of bytes.RIGHTB: Returns the right portion of a string up to a certain number of bytes.