Results for “string”
Small, practical examples. Search by task or narrow things down below.
Copy a flash string into a bounded RAM buffer
Arduino / C: strncpy_P reads from program memory into ordinary RAM.
Arduino / C✓ Tested
Copy a string with a guaranteed terminator
Arduino / C: Reserve one character for the terminator when copying a bounded string.
Arduino / C✓ 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
Distinguish unset variables from empty strings
Bash Scripts: Omitting the colon tests only whether a variable is unset; including it also treats an empty value as missing.
Bash Scripts✓ Tested
Extract a known substring
PowerShell: Substring uses a zero-based starting index and a character count.
PowerShell✓ Tested
Extract a section of an Arduino String
Arduino / C: substring includes the start index and excludes the end index.
Arduino / C✓ Tested
Extract a substring by offset and length
Bash Scripts: Bash substring offsets start at zero for an ordinary string.
Bash Scripts✓ Tested
Extract a substring with an explicit count
C++: The second substr argument is a length rather than an ending index.
C++✓ Tested
Extract a substring with range syntax
C#: C# range ends are exclusive; indices operate on UTF-16 code units.
C#✓ Tested
Extract part of a string
Use one-based positions with substr.
substr✓ Tested
Find a commit that changed the count of a text string
Git: The pickaxe -S option finds commits that add or remove occurrences of a literal string.
Git✓ Tested