Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4115250
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:33:28+00:00 2026-05-20T22:33:28+00:00

I have a ruby file with only these two lines: # encoding: utf-8 puts

  • 0

I have a ruby file with only these two lines:

# encoding: utf-8
puts "—"

When I run it with ruby test_enc.rb it fails with:

test_enc.rb:2: invalid multibyte char (UTF-8)
test_enc.rb:2: unterminated string meets end of file

I don’t know how to properly specify the character code of — (emdash), but vim tells me it is 151, Hex 97, Octal 227. It fails the same way with other characters like ã as well, so I doubt it is related specifically to that character.
I am running on Windows XP and the version of ruby I’m using is:

ruby 1.9.1p430 (2010-08-16 revision 28998) [i386-mingw32]

I feel like there is something very obvious I am missing here. Any ideas?

EDIT: Learned a valuable lesson about assumptions today – specifically assuming your editor IS using UTF-8 without actually checking it. Oops!

Thanks for the quick and accurate replies all!

EDIT AGAIN: The ‘setting up vim properly for utf-8’ grew too big and wasn’t really relevant to this question, so it is now a separate question.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T22:33:29+00:00Added an answer on May 20, 2026 at 10:33 pm

    Given that Ruby is explicitly calling your attention to UTF-8, I strongly suspect that you haven’t actually written out a UTF-8 file to start with. Make sure that Vim (or whatever text editor you’re using to create the file) is really set to write out UTF-8.

    Note that in UTF-8, any non-ASCII character will be represented by multiple bytes, not a single byte as you’ve described from the Vim diagnostics. I’d recommend using a binary file editor (or dump, or whatever) to really show what’s in the text file though. Something that doesn’t already have some preconceived notion of the encoding – something that isn’t even trying to think of it as a text file.

    Notepad lets you write out a file in UTF-8, so you might want to try that just to see what happens. (I don’t have Ruby installed myself, otherwise I’d try it for you.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ruby file as follows: module Example class Myclass def t_st Hello
so i have ruby script that simply writes to a test.txt file with hello
I have a ruby bash script to download a zip file and output a
I am reading one file using ruby in which I have written regexp in
I am using Ruby (1.9.3) and Rails (3.2.2). I have tasks file which contains
I install plugin open_id_authentication and have this error: /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:167:in `require': no such file to
I have Ruby script that creates a proxy so that I can make HTTP
I have ruby on rails installed on my ubuntu 8.10 desktop. Script/generate came up
I have Ruby on Rails 3.1 application and i use for Sphinx + Thinking
I currently have Ruby on Rails installed via RVM in Ubuntu 12.04. The default

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.