Ruby error invalid multibyte char (US-ASCII)

I am trying to run a ruby ​​script found here

but i get an error

invalid multibyte char (US-ASCII)

for line 12, which

http = Net::HTTP.new("twitter.com", Net::HTTP.https_default_port())

can someone explain to me what this means and how I can fix it, thanks

+4
source share
2 answers

When running the script with Ruby 1.9, change the first two lines of the script to:

#!/usr/bin/env ruby
# encoding: utf-8
require 'net/http'

This tells Ruby to run a character set script UTF-8. Without this line, Ruby 1.9 will have a character set by default US_ASCII.

: Ruby 1.8, 1.8 . Ruby 2.0, Ruby 2.0 UTF-8.

+12

, , Ruby . Ruby, :

# coding: utf-8

Ruby, .

+3

All Articles