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

  • SEARCH
  • Home
  • 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 1069791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:28:22+00:00 2026-05-16T20:28:22+00:00

I just upgraded from Ruby 1.8 to 1.9, and most of my text processing

  • 0

I just upgraded from Ruby 1.8 to 1.9, and most of my text processing scripts now fail with the error invalid byte sequence in UTF-8. I need to either strip out the invalid characters or specify that Ruby should use ASCII encoding instead (or whatever encoding the C stdio functions write, which is how the files were produced) — how would I go about doing either of those things?

Preferably the latter, because (as near as I can tell) there’s nothing wrong with the files on disk — if there are weird, invalid characters they don’t appear in my editor…

  • 1 1 Answer
  • 3 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-16T20:28:23+00:00Added an answer on May 16, 2026 at 8:28 pm

    What’s your locale set to in the shell? In Linux-based systems you can check this by running the locale command and change it by e.g.

    $ export LANG=en_US
    

    My guess is that you are using locale settings which have UTF-8 encoding and this is causing Ruby to assume that the text files were created according to utf-8 encoding rules. You can see this by trying

    $ LANG=en_GB ruby -e 'warn "foo".encoding.name'
    US-ASCII
    $ LANG=en_GB.UTF-8 ruby -e 'warn "foo".encoding.name'
    UTF-8
    

    For a more general treatment of how string encoding has changed in Ruby 1.9 I thoroughly recommend
    http://blog.grayproductions.net/articles/ruby_19s_string

    (code examples assume bash or similar shell – C-shell derivatives are different)

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

Sidebar

Related Questions

I just upgraded from VS2010 RC to RTM. Now my areas aren't working. I
I just upgraded from rails 2.3.5 to rails 2.3.8, but now my redirects are
I just upgraded from Xcode 4 to Xcode 4.2 and now I'm getting the
I have just upgraded the application from Rails 2 to Rails 3 (ruby 1.9.2-head).
I just upgraded from Flash Builder 4.5 to Flash Builder 4.6. Now when I
Ive upgraded rails from 3.0.10 to 3.1.1 and now Im getting the following Error:
I just upgraded from cakePHP 1.2.8 to 1.3.5 and now the debug information (that
Hi I've just upgraded from 1.5 of Tortoisesvn to 1.6 and most of my
I just upgraded from VS2008 to VS2010. In the process, I allowed it to
I just upgraded from Rails 3.0.3 to 3.2.1. The upgrade went smoothly on my

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.