Ruby 1.9: invalid multibyte char (US-ASCII)

If you ever get an error like this:

invalid multibyte char (US-ASCII)

when running a ruby script with ruby 1.9 containing non ASCII chars like ‘ä’, ‘ü’, ‘ö’ etc changes are good that you forgot to add a

# coding: utf-8

statement at the beginning of the file.

About these ads

About troessner

I am a Ruby enthusiast currently working for dealvertise in Berlin. I like dynamic languages in general with a strong focus on Ruby. Headhunters, don't bother. No, I do NOT want to be a Java architect for a mid-size company in the middle of nowhere. I probably would love Python if it wouldn't force me to write `self` all over the goddamn place. I really suck at functional programming. I should have paid more attention at university. NoSQL is worth the hype. Or is it? I am a big advocate of Behavior Driven Development. Yes, really. I tried to love node.js, but in the end, it's still fucking javascript. I was a devoted SCRUM believer. I have a deep interest in Erlang but haven't had a chance to really use it. I try to contribute as much as possible to open source. Right now I am the maintainer of the transitions gem (, the ecircle gem ( and the has_uuid gem ( Besides that I recently got fascinated with Rubinius and I am trying to really understand why this works. Furthermore, I have made some rather petty contributions to Rubinius: You can find most of the code I write on github - Sometimes I write down stuff on:
This entry was posted in Uncategorized and tagged . Bookmark the permalink.

4 Responses to Ruby 1.9: invalid multibyte char (US-ASCII)

  1. Marcin says:

    Great that you posted it. Seems to be a small thing, but it saved me some time googling !

  2. martijn says:

    why is it coding: utf-8 and not encoding ?? I tried with encoding which seems to be the convention but it didn’t work..


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s