Class: FFI::Chm::Struct::System

Inherits:
BinData::Record
  • Object
show all
Defined in:
lib/ffi-chm/struct/system.rb

Defined Under Namespace

Classes: Code3, Code4, Code6, NoRecordError, SystemRecord

Constant Summary collapse

LCID2ENCODING =
{
  1041 => "CP932", # SJIS
  2052 => "CP936" # GB2313
}

Instance Method Summary collapse

Instance Method Details

#encodingObject



23
24
25
# File 'lib/ffi-chm/struct/system.rb', line 23

def encoding
  LCID2ENCODING[self.record(4).data.lcid.to_i] || "CP1252" # ANSI
end

#record(code) ⇒ Object

Raises:



12
13
14
15
16
# File 'lib/ffi-chm/struct/system.rb', line 12

def record(code)
  @memo ||= Hash[*records.map{|v|[v.code.to_i, v]}.flatten]
  raise NoRecordError, "/#SYSTEM has no record code:#{code}" unless @memo.has_key? code
  @memo[code]
end