我有一个简单的基于机架的 ruby 服务器,我使用 Thin 运行它,它看起来像:
#encoding: utf-8
class Auth
def initialize(app)
@app = app
end
def call(env)
@request = Rack::Request.new(env).params
command = @request['command']
begin
command.tr!('٠١٢٣٤٥٦٧٨٩','0123456789')
rescue Exception => e
$LOG.error e.to_s
end
end
end
如您所见,它应该将数字从阿拉伯语翻译成英语,无论如何,当我发送参数命令“١”时,我收到了这个错误:
incompatible character encodings: ASCII-8BIT and UTF-8