我正在使用来自https://github.com/ongair/whatsapi的 whatsapi ruby 端口,在 rails 控制台中尝试 gem 时出现以下错误。我的代码是utf8,有人知道怎么解决吗?宝石的作者没有回应...
补充:中的违规代码如下:
..
elsif count < 256
@output += "\xf8" + count.chr
..
@output 编码为 utf-8
client = Whatsapi::Client.new("41791111111", "", "mynick")
#<Whatsapi::Client:0x00000008ff0bb0 @phone_number="41791111111", @name="mynick", @identity="16d922bd096238946f2b5692fb01a5021eeaefab", @login_status="disconnected", @writer=#<Whatsapi::BinTreeWriter:0x00000008fe8988 @output="">, @reader=#<Whatsapi::BinTreeReader:0x00000008fe8550>>
>> client.connect
#<TCPSocket:fd 7>
>> client.login "asdf"
Encoding::CompatibilityError: incompatible character encodings: UTF-8 and ASCII-8BIT
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/bundler/gems/whatsapi-31f8cd9b826a/lib/whatsapi/bin_tree_writer.rb:119:in `write_token'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/bundler/gems/whatsapi-31f8cd9b826a/lib/whatsapi/bin_tree_writer.rb:72:in `write_string'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/bundler/gems/whatsapi-31f8cd9b826a/lib/whatsapi/bin_tree_writer.rb:61:in `block in write_attributes'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/bundler/gems/whatsapi-31f8cd9b826a/lib/whatsapi/bin_tree_writer.rb:60:in `each'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/bundler/gems/whatsapi-31f8cd9b826a/lib/whatsapi/bin_tree_writer.rb:60:in `write_attributes'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/bundler/gems/whatsapi-31f8cd9b826a/lib/whatsapi/bin_tree_writer.rb:27:in `start_stream'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/bundler/gems/whatsapi-31f8cd9b826a/lib/whatsapi/client.rb:54:in `do_login'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/bundler/gems/whatsapi-31f8cd9b826a/lib/whatsapi/client.rb:44:in `login'
from (irb):12
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/railties-4.1.3/lib/rails/commands/console.rb:90:in `start'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/railties-4.1.3/lib/rails/commands/console.rb:9:in `start'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/railties-4.1.3/lib/rails/commands/commands_tasks.rb:69:in `console'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/railties-4.1.3/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/railties-4.1.3/lib/rails/commands.rb:17:in `<top (required)>'
from C:/Users/mike/Dropbox/kalenderfee/webapp/bin/rails:4:in `require'
from C:/Users/mike/Dropbox/kalenderfee/webapp/bin/rails:4:in `<top (required)>'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/ruby-debug-ide-0.4.30/lib/ruby-debug-ide.rb:86:in `debug_load'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/ruby-debug-ide-0.4.30/lib/ruby-debug-ide.rb:86:in `debug_program'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/ruby-debug-ide-0.4.30/bin/rdebug-ide:121:in `<top (required)>'
from -e:1:in `load'
from -e:1:in `<main>'