> Create string t containing the same characters as string s, in reverse order. Original string s must remain unaltered. Each character must be handled correctly regardless its number of bytes in memory.
What encoding? Assuming UTF-8, what is a "character"? A code point? A grapheme? The result of the lack of specification is that the different approaches really solve different problems. Some, like the C implementation, have a naive approach that only solves the problem in fixed size encodings where the width is equal to CHAR_BIT. Others I'm sure run into problems with combining characters
Comments
On a related note, the problem is underspecified.
> Create string t containing the same characters as string s, in reverse order. Original string s must remain unaltered. Each character must be handled correctly regardless its number of bytes in memory.
What encoding? Assuming UTF-8, what is a "character"? A code point? A grapheme? The result of the lack of specification is that the different approaches really solve different problems. Some, like the C implementation, have a naive approach that only solves the problem in fixed size encodings where the width is equal to CHAR_BIT. Others I'm sure run into problems with combining characters
Submit a task/"idiom" with an improved/stricter spec and link back to the original one.