Brent Roman wrote:
> class ByteString < String
I'm not sure if we need it...but it's more OO and looks nice.
how would we use it though? you don't declare variables in Ruby. Strings
are mostly generated by I/O methods (I guess File.open does return a
byte string if you read binary) and via literals (which have the default
encoding). no place for ByteString.new.

but force_encoding(nil) seems a bit ugly as a general pattern for binary
mode string handling. a String#binary proxy would be nice:

  s = MyDatabase.get_some_big_value
  s.upcase!

  result = nil
  s.binary.tap do |b|
    b.class  # => ByteStringProxy (for s)
    # do some neat binary stuff, like encryption or compression
    result = binary_stuff(s)
  end

  MyDatabase.write_some_big_value result

  # s may be misencoded here, but still has the old encoding.

here's another one:

  s.binary!  # force_encoding(nil)

[murphy]