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.83 lib/open_classes/file.rb
tbpgr_utils-0.0.82 lib/open_classes/file.rb
tbpgr_utils-0.0.81 lib/open_classes/file.rb
tbpgr_utils-0.0.80 lib/open_classes/file.rb
tbpgr_utils-0.0.79 lib/open_classes/file.rb
tbpgr_utils-0.0.78 lib/open_classes/file.rb
tbpgr_utils-0.0.77 lib/open_classes/file.rb
tbpgr_utils-0.0.76 lib/open_classes/file.rb
tbpgr_utils-0.0.75 lib/open_classes/file.rb
tbpgr_utils-0.0.74 lib/open_classes/file.rb
tbpgr_utils-0.0.73 lib/open_classes/file.rb
tbpgr_utils-0.0.72 lib/open_classes/file.rb
tbpgr_utils-0.0.71 lib/open_classes/file.rb
tbpgr_utils-0.0.70 lib/open_classes/file.rb
tbpgr_utils-0.0.69 lib/open_classes/file.rb
tbpgr_utils-0.0.68 lib/open_classes/file.rb
tbpgr_utils-0.0.67 lib/open_classes/file.rb
tbpgr_utils-0.0.66 lib/open_classes/file.rb
tbpgr_utils-0.0.65 lib/open_classes/file.rb
tbpgr_utils-0.0.64 lib/open_classes/file.rb