Strings, Unicode, and standard containers
Byte strings, code points, sequence and associative ownership
std::string owns contiguous bytes. string_view borrows bytes and carries a length; it need not end at a null terminator. A UTF-8 string's size counts code units, not Unicode code points or visible grapheme clusters. std::u32string stores code points but still does not make a combining sequence a single visible character.
std::string bytes="é"; // UTF-8 source execution encoding: usually two bytes
Text points=U"é"; // one char32_t code point
std::string embedded("a\0b",3); // size 3, despite the embedded NULChoose container semantics before choosing syntax. A vector owns contiguous elements and supports fast indexed access, but growth can invalidate pointers. A deque supports cheap growth at both ends, with different iterator invalidation rules. A list keeps node addresses stable across insertions but adds allocation and poor locality. An ordered map provides sorted keys and logarithmic lookup; an unordered map provides expected constant lookup without deterministic iteration order. operator[] on a map inserts a missing key, so it can mutate state during what looks like a read; use find/contains for read-only membership.
std::map<std::string,Int> counts;
auto found=counts.find("missing"); // no insertion
// counts["missing"] would create an entry containing zero.UTF-8 decoding validates more than continuation-byte shape. Reject overlong encodings, surrogate code points, and values above U+10FFFF. A valid four-byte sequence is one output code point. An invalid byte sequence must not be silently accepted as text or passed to locale-dependent cctype functions. Always convert a byte to unsigned char before numeric bit inspection; signed char can otherwise sign-extend high bytes. A decoded string owns its code points and remains valid after the original bytes change. This exercise deliberately does not normalize, casefold, or combine graphemes.
Put it into practice
Implement the exercise in a full-screen workspace, then run its tests.