On Feb 25, 2011, at 4:52 AM, Martin J. D=FCrst wrote:

> string.force_encoding(ENCODING::BINARY).slice almost does what you =
want, very efficiently. The problem is that the string will then be =
marked as BINARY. This can be set back, but it may affect operations =
that run in parallel. To expand on this, something like

Isn't any manipulation of a string via two threads simultaneously =
already not thread safe?

That is to say, toggling the encoding doesn't make the situation any =
worse than it is with String#slice all by itself.

Gary Wright=