What is the inspect property of encoding in Ruby?

Overview

In Ruby, the inspect property is used to return the string representing the encoding for programmers.

Syntax

Encoding::encoding.inspect

Return value

It returns a string value that represents the encoding encoding for programmers.

Code example

# get encoding for programmers
puts "#{Encoding::UTF_8.inspect}"
puts "#{Encoding::UTF_7.inspect}"
puts "#{Encoding::UTF_16.inspect}"
puts "#{Encoding::ISO_8859_1.inspect}"
puts "#{Encoding::Windows_1250.inspect}"

Explanation

  • Line 2–6: We get the string for the programmer encodings and print it to the console.

Free Resources