tmm1 / amqp

AMQP client implementation in Ruby/EventMachine
http://groups.google.com/group/ruby-amqp
444 stars 5 forks source link

With ruby 1.9, Queue#publish wouldn't work for multi-byte characters. #14

Closed kei-s closed 13 years ago

kei-s commented 14 years ago

With ruby 1.9 (tested with 1.9.1p378), Queue#publish wouldn't work for multi-byte characters.

#encoding:utf-8
require 'rubygems'
require 'mq'

AMQP.start do
  queue = MQ.queue('rubyist')
  EM.add_periodic_timer(1) do
    queue.publish("matz")
    queue.publish("まつもとゆきひろ")
  end
end
#=> publish only "matz"
kei-s commented 14 years ago

I think it is caused by using String#length to get byte size in lib/amqp/buffer.rb.

dyoung commented 14 years ago

Does this still happen? I haven't run into it yet, but I encode everything with AES before sending. I guess you could try to Base64 encode stuff (and then decode, yeah, annoying).

kei-s commented 14 years ago

Yes, this still happen. I agree to use Base64, but it's not quite right :(

dagi3d commented 13 years ago

same here. any solution? thanks!

kasperbn commented 13 years ago

I can confirm this with rabbitmq. I get a bad_payload exception in the rabbitmq log. It works with ISO-8859-1 but that is not quite right either.

kasperbn commented 13 years ago

I've fixed this in this pull request: http://github.com/tmm1/amqp/pull/28

ghost commented 13 years ago

I tested kasperbn's patch, it works pretty good.

botanicus commented 13 years ago

Closed by ee9ad7154e81dda5f5cf2b668876bc89840c84e5 - With ruby 1.9, Queue#publish wouldn't work for multi-byte characters.

Changed data.length to data.bytesize