Class: UTF8Encoder

Inherits:
Object
  • Object
show all
Defined in:
lib/utf8encoder.rb

Instance Method Summary collapse

Constructor Details

#initialize(bom, current_encoding = 'utf-8') ⇒ UTF8Encoder

Returns a new instance of UTF8Encoder.



3
4
5
# File 'lib/utf8encoder.rb', line 3

def initialize(bom,current_encoding='utf-8')
  @converter = Iconv.new('utf-8',current_encoding)
end

Instance Method Details

#encode(string) ⇒ Object



6
7
8
# File 'lib/utf8encoder.rb', line 6

def encode(string)
  "\xEF\xBB\xBF"<<@converter.iconv(string)
end