1

I've searched all over and tried everything but I still get:

invalid multibyte char (UTF-8) 

When doing something like:

some_string.gsub(/…/) 

Even though I added this to the top of the file:

# encoding: utf-8 

Any help?

2
  • 2
    I made a quick test file and it works for me. (ruby 1.9.3). How are you running your file? Commented Mar 29, 2012 at 17:45
  • 1
    Is your editor actually saving your code in UTF-8? Commented Mar 29, 2012 at 18:32

1 Answer 1

2

Try:

some_string.gsub(/\u2026/) 

You can also take a look at this question for more information.

Sign up to request clarification or add additional context in comments.

4 Comments

Good quick fix. But still would be nice to use the actual UTF-8 character.
Did you make sure the file was actually Unicode-encoded? You can also try to run the ruby script with the -Ku option
That option is actually for 1.8 and if he were using 1.8 he wouldn't even need it.
Im using 1.9.3. Textmate. The file is actually saved as UTF-8.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.