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

Popular posts from this blog

psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

CARRIERWAVE - UPLOAD ANY MEDIA (AUDIO , VIDEO AND IMAGE ) FILE IN RAILS

SELECT COUNTRY WITH STATE AND IT'S CITIES RAILS

RAILS: UPLOADING PHOTOS VIA AMAZON S3 AND PAPERCLIP (UPLOADING FILES TO S3 IN RUBY WITH PAPERCLIP)

SEARCHING USING AJAX IN RAILS

UPLOAD ANY MEDIA FILE IN RAILS USING PAPERCLIP

UNINITIALIZED CONSTANT PAPERCLIP::STORAGE::S3::AWS

CURL COMMAND ON RUBY ON RAILS

CHECK PASSENGER RUBY PATH