Results for “byte”
Small, practical examples. Search by task or narrow things down below.
Count newline characters
Count newline bytes in a C file while retaining EOF as an int.
C✓ Tested
Decode a 16-bit big-endian integer
C: Promote bytes to an unsigned integer type before combining shifted values.
C✓ Tested
Encode and decode binary data as Base64
Python: Use Base64 when a text format must carry bytes; it is encoding, not encryption.
Python✓ Tested
Encode and decode UTF-8 text with Base64
PowerShell: Convert the string to bytes explicitly before Base64 encoding.
PowerShell✓ Tested
Format several integers in a fixed buffer
Arduino / C: snprintf limits writes to the buffer size and includes a terminating null byte.
Arduino / C✓ Tested
Give an LED pin a constant name
Arduino / C: Use const to name the built-in LED pin and reuse it in output instructions.
Arduino / C✓ Tested
Handle incomplete serial input
Arduino / C: The returned byte count distinguishes a complete payload from a timed-out partial one.
Arduino / C✓ Tested
Inspect a file length without reading it
C#: Use FileInfo.Length to retrieve a logical size in bytes.
C#✓ Tested
Measure a short text value
Python: Read the length of an ASCII string. Non-ASCII text may use multiple code units or bytes depending on the language.
Python✓ Tested
Measure a short text value
C#: Read the length of an ASCII string. Non-ASCII text may use multiple code units or bytes depending on the language.
C#✓ Tested
Measure a short text value
Java: Read the length of an ASCII string. Non-ASCII text may use multiple code units or bytes depending on the language.
Java✓ Tested
Measure a short text value
JavaScript: Read the length of an ASCII string. Non-ASCII text may use multiple code units or bytes depending on the language.
JavaScript✓ Tested