FIND YOUR NEXT FEW LINES

Results for “Strings & byte buffers”

Small, practical examples. Search by task or narrow things down below.

195 snippets foundClear filters
JavaScriptStrings

Check for a substring

Perform a case-sensitive JavaScript substring check.

JavaScript✓ Tested
JavaStrings

Check whether text contains a phrase

Use a case-sensitive Java substring check.

Java✓ Tested
CSmall algorithms & bit operations

Compute a simple XOR checksum

C: XOR all payload bytes into one byte to demonstrate a basic error-detection field.

C✓ Tested
C++Text validation & parsing

Convert ASCII text to lowercase safely

C++: Cast each byte to unsigned char before using the cctype function.

C++✓ Tested
CStrings

Convert ASCII text to uppercase

Convert characters with toupper while avoiding signed-char undefined behavior.

C✓ Tested
CStrings

Copy text into a fixed buffer

Use snprintf and check for truncation when copying a C string.

C✓ Tested
CFiles

Count newline characters

Count newline bytes in a C file while retaining EOF as an int.

C✓ Tested
CBinary formats & structured parsing

Decode a 16-bit big-endian integer

C: Promote bytes to an unsigned integer type before combining shifted values.

C✓ Tested
PythonText validation & encoding

Encode and decode binary data as Base64

Python: Use Base64 when a text format must carry bytes; it is encoding, not encryption.

Python✓ Tested
PowerShellStructured formats & encodings

Encode and decode UTF-8 text with Base64

PowerShell: Convert the string to bytes explicitly before Base64 encoding.

PowerShell✓ Tested
PythonStrings & dates

Extract numbers from text

Find all runs of ASCII digits in a string and convert the matches to integers.

regex✓ Tested
C++Strings

Find a substring

Check the result of std::string::find against npos.

C++✓ Tested