Help us understand the problem. What is going on with this article?

Rubyでつまずいた備忘録

More than 5 years have passed since last update.

Chris Pine著 初めてのプログラミング でRubyを勉強してみてつまずいた箇所の
自分勝手な備忘録です。

初めての躓きポイント。
getsメソッドで対話的なプログラムを記述したときのエラー。
本に書いてある通りに記述して

example.rb
  puts 'こんにちはあなたのお名前は?'
  name = gets.chomp
  puts 'あなたは'+name+'さんですね?すばらしい名前ですね'
  puts 'お会い出来て光栄です'+name+'さん:)'

を実行すると

terminal
  invalid multibyte char (US-ASCII)

とエラーが出る。

charと言ってるくらいなので文字コードの指定だろうと思い調べてみたらありました。

# encoding: utf-8 もしくは -*- encoding: UTF-8 -*- を先頭に記述で問題なく解決。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした