getByteSize
function getByteSize(value: string): number;
Read the caveat before using this. The name and the original intent are the UTF-8 byte length, but as it stands the function counts UTF-16 code units and only widens the first surrogate it meets. An ASCII string measures correctly; anything outside ASCII — Cyrillic, Greek, CJK, an emoji — measures short. Until that is fixed, measure a payload with Utilities.newBlob(text).getBytes().length instead.
Parameters
Parameter | Type | Description |
|---|---|---|
|
| The string to measure. |
Returns
number — the length, in code units.
Throws
Exception | Condition |
|---|---|
| the value is not a string. |
Examples
In use
getByteSize("abc"); // => 3
See also
Source
23 September 2026
This documentation was generated with AI (Claude) from the library's source code.