Given a multibyte string "x=π", how to get 4-th byte of the string,
without creating string copy with something like string-as-unibyte?
Pseudo code: (string-nth-byte 4 "x=π").
Expected result: 128.
"x=π" = [120 61 207 128] <- bytes
0 1 2 3 <- index
Any solution that is reasonably efficient is considered valid.
O(1) run time complexity is preferred.
If there is Emacs builtin for that, I will be very happy.
Notes:
- Allocations must be avoided;
get-bytefails on multibyte chars;- I am aware of unibyte strings. They are not the answer;
If you ask: "Why on earth you need to do this?", the answer is this.