For example, you might think that reversing a string is equivalent to reversing its characters. It's not.
Similarly, you might think that indexing a string is the same as indexing a list. It's not.
Etc etc.
For example, you might think that reversing a string is equivalent to reversing its characters. It's not.
Similarly, you might think that indexing a string is the same as indexing a list. It's not.
Etc etc.
I'm not sure what you mean by reversing a string not being equal to reversing its characters. It's certainly not always equal to reversing its bytes (depending on the encoding). Same goes for Strings that are implemented with UTF-16 characters (e.g. Java, win32 wchar_t etc.) all suffer from bad abstractions driven by implementation/efficiency concerns.
From a programming language perspective, I think it would be ideal if strings could always be viewed as lists of encoding independent characters, such that reversing this list is equivalent to reversing the string.
If you want to be able to maintain a one-to-one mapping to unicode, you will need to use unique characters for an "ä" and an "a with combining-diaeresis" but ideally that should be hidden from the user of the language.
Thus, in my ideal world, both "LATIN-SMALL-LETTER-O-WITH-DIAERESIS" and "LATIN-SMALL-LETTER-O COMBINING-DIAERESIS" would each be one single element of a list of characters which is a string.
foo\r\n\bar
I imagine the most useful answer if you are writing a notepad-level application would be: rab\r\n\oofA string is more like a bytecode program that can be executed to evaluate to a piece of human-readable text.