Sha256: 69721e0388ea6706fb974d0f8b086ad07eadb8c85d16f575298686c434791cbd

Contents?: true

Size: 714 Bytes

Versions: 133

Compression:

Stored size: 714 Bytes

Contents

require 'tins/concern'

module Tins
  module StringByteOrderMark
    def bom_encoding
      prefix = self[0, 4].force_encoding(Encoding::ASCII_8BIT)
      case prefix
      when /\A\xef\xbb\xbf/n                    then Encoding::UTF_8
      when /\A\x00\x00\xff\xfe/n                then Encoding::UTF_32BE
      when /\A\xff\xfe\x00\x00/n                then Encoding::UTF_32LE
      when /\A\xfe\xff/n                        then Encoding::UTF_16BE
      when /\A\xff\xfe/n                        then Encoding::UTF_16LE
      when /\A\x2b\x2f\x76[\x38-\x39\x2b\x2f]/n then Encoding::UTF_7
      when /\A\x84\x31\x95\x33/n                then Encoding::GB18030
      end
    end
  end
end

require 'tins/alias'

Version data entries

133 entries across 115 versions & 9 rubygems

Version Path
tins-1.37.0 lib/tins/string_byte_order_mark.rb
tins-1.36.1 lib/tins/string_byte_order_mark.rb
tins-1.36.0 lib/tins/string_byte_order_mark.rb
tins-1.35.0 lib/tins/string_byte_order_mark.rb
tins-1.34.0 lib/tins/string_byte_order_mark.rb
tins-1.33.0 lib/tins/string_byte_order_mark.rb
tdiary-5.2.4 vendor/bundle/ruby/3.1.0/gems/tins-1.31.1/lib/tins/string_byte_order_mark.rb
tins-1.32.1 lib/tins/string_byte_order_mark.rb
tins-1.32.0 lib/tins/string_byte_order_mark.rb
tdiary-5.2.3 vendor/bundle/ruby/3.1.0/gems/tins-1.31.1/lib/tins/string_byte_order_mark.rb
tdiary-5.2.2 vendor/bundle/ruby/3.1.0/gems/tins-1.31.1/lib/tins/string_byte_order_mark.rb
tins-1.31.1 lib/tins/string_byte_order_mark.rb
tdiary-5.2.1 vendor/bundle/ruby/3.1.0/gems/tins-1.31.0/lib/tins/string_byte_order_mark.rb
tins-1.31.0 lib/tins/string_byte_order_mark.rb
tins-1.30.0 lib/tins/string_byte_order_mark.rb
tdiary-5.2.0 vendor/bundle/ruby/2.7.0/gems/tins-1.29.1/lib/tins/string_byte_order_mark.rb
tdiary-5.2.0 vendor/bundle/ruby/3.0.0/gems/tins-1.29.1/lib/tins/string_byte_order_mark.rb
tdiary-5.1.7 vendor/bundle/ruby/2.7.0/gems/tins-1.29.1/lib/tins/string_byte_order_mark.rb
tdiary-5.1.7 vendor/bundle/ruby/3.0.0/gems/tins-1.29.1/lib/tins/string_byte_order_mark.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/tins-1.26.0/lib/tins/string_byte_order_mark.rb