{"action":"opened","issue":{"number":18,"created_at":"2011-10-11T18:00:33Z","pull_request":{"diff_url":null,"patch_url":null,"html_url":null},"body":"I have a  CassandraCQL::Database @handle. Calling\r\n```@handle.execute(\r\n   \"insert into anonymized (KEY,  ?) values (?)\", \r\n   '345c1fa8-f430-11e0-8a3e-8b6c152b4342__88:45:25:BD:0E:06',\r\n   '{\"some_json_in_utf8:\"æ\"}'\r\n)```\r\n\r\nresults in an exception:\r\n```Encoding::CompatibilityError: incompatible character encodings: ASCII-8BIT and UTF-8\r\n     /my_rvm_gemset/gems/thrift-0.6.0/lib/thrift/transport/framed_transport.rb:57:in `write'\r\n     /my_rvm_gemset/gems/thrift-0.6.0/lib/thrift/protocol/binary_protocol.rb:107:in `write_string'\r\n     /my_rvm_gemset/gems/thrift-0.6.0/lib/thrift/client.rb:35:in `write'\r\n     /my_rvm_gemset/gems/thrift-0.6.0/lib/thrift/client.rb:35:in `send_message'\r\n     /my_checked_out_gems/cassandra-cql/vendor/gen-rb/cassandra.rb:520:in `send_execute_cql_query'\r\n     /my_checked_out_gems/cassandra-cql/vendor/gen-rb/cassandra.rb:515:in `execute_cql_query'\r\n     /my_rvm_gemset/bundler/gems/thrift_client-caed05a1321c/lib/thrift_client/abstract_thrift_client.rb:150:in `handled_proxy'\r\n     /my_rvm_gemset/bundler/gems/thrift_client-caed05a1321c/lib/thrift_client/abstract_thrift_client.rb:60:in `execute_cql_query'\r\n     /my_checked_out_gems/cassandra-cql/lib/cassandra-cql/database.rb:72:in `execute_cql_query'\r\n     /my_checked_out_gems/cassandra-cql/lib/cassandra-cql/statement.rb:35:in `execute'\r\n     /my_checked_out_gems/cassandra-cql/lib/cassandra-cql/database.rb:61:in `execute'\r\n     /my_code.rb:1234:in `anonymized`\r\n```\r\n\r\nHere's the code where it blows up:\r\n```\r\n    def write(buf,sz=nil)\r\n      return @transport.write(buf) unless @write\r\n      @wbuf << (sz ? buf[0...sz] : buf)\r\n    end\r\n```\r\nIt  looks like @wbuf is trying to be a buffer of binary data (?) but it is treated by Ruby as an encoded string (note the ```# encoding: ascii-8bit``` comment at the top). Interestingly, if I modify database.rb such that execute passes along ```:compression => true``` the insert is successful; presumably the value is encapsulated in a better way. (I'm still working on *retrieving* the value without corruption, though.)\r\n\r\nI am not sure about how the data behaves once it's on the other side of the protocol, but it would probably be best if strings of any sort could be used with the cassandra-cql gem transparently, especially UTF-8 strings.","comments":0,"title":"UTF8-encoded data produces an Encoding::CompatibilityError","updated_at":"2011-10-11T18:00:33Z","url":"https://api.github.com/repos/kreynolds/cassandra-cql/issues/18","id":1879118,"assignee":null,"milestone":null,"closed_at":null,"user":{"avatar_url":"https://secure.gravatar.com/avatar/e7f4aa3d1acdfa35716be4eaad9c07a8?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/twhaples","id":862118,"login":"twhaples"},"html_url":"https://github.com/kreynolds/cassandra-cql/issues/18","labels":[],"state":"open"},"legacy":{"number":18,"action":"opened","issue":1879118}}