Skip to content

Instantly share code, notes, and snippets.

@Burgestrand
Created October 29, 2020 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Burgestrand/693b65b0a7aae28294a271150c19dee7 to your computer and use it in GitHub Desktop.
Save Burgestrand/693b65b0a7aae28294a271150c19dee7 to your computer and use it in GitHub Desktop.
# Ruby has to assume the input comes in a specific encoding. The encoding it
# *actually* comes in as depends on your system, possibly in the LOCALE env?
STDIN.set_encoding(Encoding::UTF_8)
require "io/console" # for IO#getch
c = STDIN.getch
puts c
puts c.bytesize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment