Sha256: 7b9440a6eb7a6161278c474e9d8c938b5cbd8f9fe9e3c4a221d43a6d1e3b0ac6

Contents?: true

Size: 635 Bytes

Versions: 76

Compression:

Stored size: 635 Bytes

Contents

# encoding: utf-8

# File
class File
  # insert BOM to UTF-8 File
  #
  # this method's main purpose is 'UTF-8 Excel CSV File'.
  #
  # File.insert_bom("input.csv", "output.csv") # => output bommed text to output.csv
  # File.insert_bom("input.csv") # => output bommed text to input.csv
  def self.insert_bom(input_filename, output_filename = nil)
    src = File.read(input_filename)
    output_filename ||= input_filename
    File.open(output_filename, 'w:UTF-8') do |f|
      src = '   ' + src
      src.setbyte(0, 0xEF)
      src.setbyte(1, 0xBB)
      src.setbyte(2, 0xBF)
      f.print src
    end
  end
end

Version data entries

76 entries across 76 versions & 1 rubygems

Version Path
tbpgr_utils-0.0.63 lib/open_classes/file.rb
tbpgr_utils-0.0.62 lib/open_classes/file.rb
tbpgr_utils-0.0.61 lib/open_classes/file.rb
tbpgr_utils-0.0.60 lib/open_classes/file.rb
tbpgr_utils-0.0.59 lib/open_classes/file.rb
tbpgr_utils-0.0.58 lib/open_classes/file.rb
tbpgr_utils-0.0.57 lib/open_classes/file.rb
tbpgr_utils-0.0.56 lib/open_classes/file.rb
tbpgr_utils-0.0.55 lib/open_classes/file.rb
tbpgr_utils-0.0.54 lib/open_classes/file.rb
tbpgr_utils-0.0.53 lib/open_classes/file.rb
tbpgr_utils-0.0.52 lib/open_classes/file.rb
tbpgr_utils-0.0.51 lib/open_classes/file.rb
tbpgr_utils-0.0.50 lib/open_classes/file.rb
tbpgr_utils-0.0.49 lib/open_classes/file.rb
tbpgr_utils-0.0.48 lib/open_classes/file.rb
tbpgr_utils-0.0.47 lib/open_classes/file.rb
tbpgr_utils-0.0.46 lib/open_classes/file.rb
tbpgr_utils-0.0.45 lib/open_classes/file.rb
tbpgr_utils-0.0.44 lib/open_classes/file.rb