Module: Encoding::CodePage
- Included in:
- Encoding
- Defined in:
- lib/encoding-codepage.rb
Overview
Encoding::Codepage adds two methods to the Encoding class to help you look Encodings by their Microsoft® Codae Page Identifier. It doesn’t add support to Ruby for Encodings that are not already supported, just makes it easier to find those encodings which are.
At the moment, this list is available on the web at:
Instance Method Summary collapse
-
#codepage(id) ⇒ Object
Find an Encoding object from a Micrsoft® Code Page Identifier.
-
#codepage?(id) ⇒ Encoding?
Determine whether a Code Page exists with the given Code Page Identifier.
-
#exist?(name) ⇒ Encoding?
Determine whether an Encoding exists with the given name.
Instance Method Details
#codepage(id) ⇒ Object
Find an Encoding object from a Micrsoft® Code Page Identifier.
A list of Code Page identifiers can be found at:
NOTE: This library doesn’t add support for all Code Pages, it merely allows you to look up existing encodings by their Code Page Identifier.
24 25 26 |
# File 'lib/encoding-codepage.rb', line 24 def codepage(id) Encoding.find("CP#{id}") end |
#codepage?(id) ⇒ Encoding?
Determine whether a Code Page exists with the given Code Page Identifier.
44 45 46 |
# File 'lib/encoding-codepage.rb', line 44 def codepage?(id) exist?("CP#{id}") end |
#exist?(name) ⇒ Encoding?
Determine whether an Encoding exists with the given name.
33 34 35 36 37 |
# File 'lib/encoding-codepage.rb', line 33 def exist?(name) find(name) rescue ArgumentError => e nil end |