Ruby: Source Code Encoding
Ruby Default Source Code Encoding
Ruby's default source code encoding is UTF-8.
you should set your text editor to save ruby file in UTF-8.
p "abc♥".encoding.name # "UTF-8"
Declare a Encoding for Ruby Source Code
Ruby allows you to use different encoding for reading ruby source code file.
put this line as the first line of the file:
# -*- coding: utf-16 -*-
This makes Unicode: UTF-16 Encoding as the source code's encoding.
This convention came from emacs. 〔see Emacs: Declare File Encoding〕
🛑 WARNING: by declaring a encoding, it also makes strings in the code in that encoding.