Results for “Text validation & encoding”
Small, practical examples. Search by task or narrow things down below.
Normalize canonically equivalent Unicode strings
C#: Normalize to NFC before an ordinal comparison of equivalent character sequences.
C#✓ Tested
Normalize equivalent Unicode strings
Python: Normalize to NFC before comparing canonically equivalent text.
Python✓ Tested
Pad a numeric label to a fixed width
C#: Use a numeric format specifier to add leading zeroes.
C#✓ Tested
Quote a literal search term for a regex
C#: Regex.Escape prevents metacharacters in a literal term from changing the pattern.
C#✓ Tested
Remove a known prefix safely
Python: Use removeprefix instead of lstrip when removing a literal prefix rather than a set of characters.
Python✓ Tested
Remove a known suffix safely
Python: Use removesuffix to remove only a matching ending.
Python✓ Tested
Validate a complete identifier with a regex
C#: Use absolute anchors and a timeout so the regex checks the complete input with a bounded execution time.
C#✓ Tested
Validate an entire identifier
Python: Use fullmatch so a regex must consume the complete input.
Python✓ Tested
Build text efficiently in a loop
Java: Append to StringBuilder when constructing a string incrementally.
Java✓ Tested
Calculate a SHA-256 text digest
Calculate a SHA-256 text digest using a complete Go program with explicit sample inputs.
Go✓ Tested
Control a multiline text field
Control a multiline text field with a small React component and explicit browser behavior.
React✓ Tested
Convert ASCII text to lowercase safely
C++: Cast each byte to unsigned char before using the cctype function.
C++✓ Tested