Methods

Files

Class/Module Index [+]

Quicksearch

Tins::StringByteOrderMark

Public Instance Methods

bom_encoding() click to toggle source
# File lib/tins/string_byte_order_mark.rb, line 5
def bom_encoding
  prefix = self[0, 4].force_encoding(Encoding::ASCII_8BIT)
  case prefix
  when /\A\xef\xbb\xbf/                         then Encoding::UTF_8
  when /\A\x00\x00\xff\xfe/                     then Encoding::UTF_32BE
  when /\A\xff\xfe\x00\x00/                     then Encoding::UTF_32LE
  when /\A\xfe\xff/                             then Encoding::UTF_16BE
  when /\A\xff\xfe/                             then Encoding::UTF_16LE
  when /\A\x2b\x2f\x76(?:[\x38-\x39\x2b\x2f]|)/ then Encoding::UTF_7
  when /\A\x84\x31\x95\x33/                     then Encoding::GB18030
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.