This time, it appeared in Chapter 1 of Introduction to Ruby for Professionals. I had a little trouble with the process of making it possible to input Japanese with irb, so I will leave it as a memorandum.
You can use irb to perform programming interactively. Without having to write to a text editor and run it in a terminal You can easily check the operation of Ruby just by writing the same contents as a text editor on irb.
(Figure: Operation check with irb)
Start irb and try Japanese input.
terminal
irb(main):001:0> '\U+FFE3\U+FFE3\U+FFE3\U+FFAB
If you are in such a situation, you will not be able to input and output Japanese. The following is the solution.
What to do if you can't enter Japanese in irb I can't input Japanese with irb, I can't specify the Ruby version with rbenv
I tried the above two, but it didn't work.
Next, when I tried it with reference to "What to do when Japanese input is garbled on Mac irb"
terminal
appurunoMacBook-Air:~ apple$ rbenv version
system (set by /Users/apple/.rbenv/version)
I didn't find "2.5.3 (set by /Users/donchan922/.rbenv/version)" that should be in the article, so I thought it was strange and searched for the version of rbenv.
"Manage ruby version with rbenv" Refer to this article and follow the steps.
terminal
appurunoMacBook-Air:~ apple$ rbenv --version
rbenv 1.1.2
appurunoMacBook-Air:~ apple$ rbenv install --list
2.5.8
2.6.6
2.7.2
jruby-9.2.13.0
maglev-1.0.0
mruby-2.1.2
rbx-5.0
truffleruby-20.2.0
truffleruby+graalvm-20.2.0
appurunoMacBook-Air:~ apple$ rbenv versions
* system (set by /Users/apple/.rbenv/version)
2.5.0
2.5.1
2.5.7
In addition to system, there are more versions! Next, I followed the steps below and started irb, and I was able to input Japanese safely.
terminal
$ rbenv global 2.5.0
$ rbenv version
2.5.0 (set by /Users/owner/.rbenv/version)
appurunoMacBook-Air:~ apple$ irb
irb(main):001:0> 'This'
=> "This"
I'm glad!
What to do if you can't enter Japanese in irb I can't input Japanese with irb, I can't specify the Ruby version with rbenv "What to do when Japanese input is garbled on Mac irb" "Manage ruby version with rbenv"