Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

ruby
name
encoding
communitycreator

What are the names property of an encoding in Ruby?

okwudili onyejiaku

Overview

When using the names for an encoding instance, a list of the name and aliases of the encoding is returned.

Syntax

Encoding::encoding_instance.names

Return value

The value returned is an array containing the names and aliases of the encoding.

Example

# get names and aliases of some encodings
puts "#{Encoding::UTF_16.names}"
puts "#{Encoding::ISO_8859_1.names}"
puts "#{Encoding::Windows_1250.names}"
Getting the names and aliases of some Encodings in Ruby

Explanation

  • Line 2–4: We get the names and aliases of some encodings in Ruby using the names property of the Encoding class instances. Then we print the values to the console.

RELATED TAGS

ruby
name
encoding
communitycreator
RELATED COURSES

View all Courses

Keep Exploring