# File lib/bson/bson_ruby.rb, line 59 def self.to_utf8_binary(str) begin str.unpack("U*") rescue => ex raise InvalidStringEncoding, "String not valid utf-8: #{str.inspect}" end str.encode(UTF8_ENCODING).force_encoding(BINARY_ENCODING) end