... unless str is _already_ UTF-8 encoded and contains character codes
0x7f. string_to_utf8() assumes that: a) str is 16- or 32-bit wide;
b) is 7-bit only; if not - it won't work as expected/intended.
No. It's *always* true.
str = string_to_utf8("\x1234\x1234");
str == "á\210´á\210´"
utf8_to_string(string_to_utf8(str));
== "á\210´á\210´", which is what is expected.