Results for “length”
Small, practical examples. Search by task or narrow things down below.
Add a multiline text field
Set a maximum length and visible rows on a labeled HTML textarea.
HTML✓ Tested
Append text only when the destination has enough capacity
C: Check the combined lengths including the terminator before using strcat.
C✓ Tested
Check a literal filename suffix
C: Check lengths before subtracting so a short input cannot produce an invalid pointer.
C✓ Tested
Check a literal string prefix
C: strncmp compares at most the prefix length; both inputs must be valid strings.
C✓ Tested
Check a literal suffix in C++17
C++: Check lengths before subtracting to avoid an unsigned underflow.
C++✓ Tested
Check EEPROM capacity before a write
Arduino / C: length reports the available address count for this board.
Arduino / C✓ Tested
Choose the smaller of a fixed and viewport-relative size
CSS: Min selects whichever supplied length is smaller at the current viewport.
CSS✓ Tested
Compare binary buffers including zero bytes
C: memcmp checks an explicit byte length rather than stopping at a string terminator.
C✓ Tested
Count bytes in a file
Linux Commands: Use wc -c for byte length rather than Unicode character count.
Linux Commands✓ Tested
Count Unicode code points in a string
JavaScript: String iteration combines surrogate pairs, unlike the UTF-16 length property.
JavaScript✓ Tested
Count Unicode code points in a string
TypeScript: String iteration combines surrogate pairs, unlike the UTF-16 length property.
TypeScript✓ Tested
Create an independent copy of a byte buffer
C: Allocate the exact byte length and copy only after checking the result.
C✓ Tested