Module: Encoding::CodePageMethods

Included in:
Encoding
Defined in:
lib/encoding-codepage.rb

Instance Method Summary collapse

Instance Method Details

#codepage_idObject

Find the code-page id that corresponds to this encoding.

Returns:

  • Integer The Code Page Identifier

Raises:

  • ArgumentError There is no Code Page Identifier for that Encoding.



85
86
87
88
89
90
91
92
93
# File 'lib/encoding-codepage.rb', line 85

def codepage_id
  if names.detect{ |x| x =~ /\ACP([0-9]+)\z/ }
    Integer($1, 10)
  elsif codepage_encoding = CodePage.reverse_lookup[self]
    codepage_encoding.codepage_id
  else
    raise ArgumentError, "No Code Page Idenfier found for: #{self}"
  end
end