In some encodings such as UTF-8, characters are of variable length in bytes. It's a bit like a tagged union, but the exact size could be computed, so the next element in a string could follow immediately, with the cost of making it almost read-only, with few, but necessary exceptions.
Many languages just work on the bytes (or two-byte pairs for UTF-16), that is, incomplete characters, and defer Unicode-related operations to libraries. Many other languages don't expose low-level interfaces for characters in strings, and use 1-character strings to represent characters when the notion of characters is needed. Some other languages make stand alone characters a different thing of fixed lengths from characters in strings.
There are also languages like Raku, which change the idea of characters to refer to grapheme clusters, so a zalgo character could be in arbitrary length, making it more complicated.
Are there previous attempts to make variable length encodings internally supported, while also having a character type that could refer to such a variable length character in a string?
(I'm thinking about the question more like how tagged unions aka sum types could be extended, instead of how strings should be implemented, which might be acceptable as a special case otherwise.)