INVALID MULTIBYTE CHAR (US-ASCII)
I was playing with Couchbase and plain Ruby in my Terminal. Then I got the error message:
invalid multibyte char (US-ASCII)
or
Message from application: /www/pro_edgudri_lv/app/models/plans_modification.rb:7: invalid multibyte char (US-ASCII)
/www/pro_edgudri_lv/app/models/plans_modification.rb:7: invalid multibyte char (US-ASCII)
/www/pro_edgudri_lv/app/models/plans_modification.rb:7: syntax error, unexpected $end, expecting keyword_end
..._change, :message => "nevar būt tukšs"
... ^ (SyntaxError)
If you got this error, you know that this is a result of having special chars. To fix this, you have to add a ‘magic comment’ in the script.
Here is a step-by-step instruction how to solve this problem:
1. Open your file
2. go to the VERY FIRST line of your code
3. write the following at the top of your file
#!/bin/env ruby
# encoding: utf-8
Example :-
payment_controller.rb:-
# encoding: utf-8
class PaymentsController < ApplicationController
end
WE CAN FOLLOW THE LINK :-
http://www.railszilla.com/invalid-multibyte-char-us-ascii-ruby/ruby
Comments