Results for “Binary formats & structured parsing”
Small, practical examples. Search by task or narrow things down below.
Search a sorted slice
Search a sorted slice in a complete Rust program using the standard library.
Rust✓ Tested
Search a sorted vector
Use binary_search after ensuring C++ values are sorted.
C++✓ Tested
Set and clear a bit in a shell integer
Bash Scripts: Use shifts and bitwise operators for a small flag field.
Bash Scripts✓ Tested
Split a record while retaining its remainder
Bash Scripts: The final read variable receives the remainder of a delimited record.
Bash Scripts✓ Tested
Test numeric divisibility with a remainder
Bash Scripts: The modulo operator computes an integer remainder.
Bash Scripts✓ Tested
Toggle a bit with an XOR mask
Arduino / C: XOR flips selected bits and leaves all other bits unchanged.
Arduino / C✓ Tested
Trim surrounding ASCII whitespace
C++: Find the first and last non-whitespace bytes before taking a substring.
C++✓ Tested
Validate a complete floating-point input
C: strtod exposes both the stopping position and range errors; reject nonfinite results when required.
C✓ Tested
Validate a complete identifier
C++: regex_match requires the pattern to match the complete input sequence.
C++✓ Tested
Visit files recursively
Java: Close the stream returned by Files.walk and sort relative paths for stable output.
Java✓ Tested
Write and read bytes without text conversion
C++: Use binary stream modes and check each I/O operation before consuming its result.
C++✓ Tested
Write and read raw bytes
C#: Use the byte-oriented file APIs when no text encoding should be applied.
C#✓ Tested