I use RestClient to retrieve a json string from a webservice via GET. This works fine but as soon as there are Umlauts (ü) and other chars (eg ß) in the string, I get this error in my view
@output = RestClient.get 'https://myurl.com/api/v1/orders/53e0ae7f6630361c46060000', {:authorization => 'Token xxxxxx', :content_type => :json, :accept => :json}
<%= @output %>
=>
Encoding::CompatibilityError
incompatible character encodings: UTF-8 and ASCII-8BIT
any idea how to solve this?
添加此行后解决
@output = @output.force_encoding('utf-8').encode
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.