The name
method of an encoding instance returns the string representation of an encoding. The string it returns is the name of the encoding.
str.encoding.name
str
: This parameter gets the encoding of a string.
A string is returned, which is the encoding’s name.
# get and print the names of# some encodings in Ruby# encode some strings.str1 = "Welcome to Edpresso".encode(Encoding::ISO_8859_1)# get name of encodingputs "The encoding name for \"#{str1}\" is #{str1.encoding.name}"
ISO_8859_1
.name
property.