In order to avoid unnecessary memory allocation, we could use an optimistic approach here:

```ruby
encoded = begin
  actual_string.force_encoding 'binary'
rescue RuntimeError
  actual_string.dup.force_encoding 'binary'
end
```