Module: GIGO

Defined in:
lib/gigo/rchardet/escsm.rb,
lib/gigo.rb,
lib/gigo/version.rb,
lib/gigo/rchardet.rb,
lib/gigo/transcoders.rb,
lib/gigo/rchardet/jpcntx.rb,
lib/gigo/rchardet/mbcssm.rb,
lib/gigo/rchardet/jisfreq.rb,
lib/gigo/rchardet/big5freq.rb,
lib/gigo/transcoders/blind.rb,
lib/gigo/rchardet/constants.rb,
lib/gigo/rchardet/escprober.rb,
lib/gigo/rchardet/euckrfreq.rb,
lib/gigo/rchardet/euctwfreq.rb,
lib/gigo/rchardet/big5prober.rb,
lib/gigo/rchardet/gb2312freq.rb,
lib/gigo/rchardet/sjisprober.rb,
lib/gigo/rchardet/utf8prober.rb,
lib/gigo/rchardet/eucjpprober.rb,
lib/gigo/rchardet/euckrprober.rb,
lib/gigo/rchardet/euctwprober.rb,
lib/gigo/transcoders/rchardet.rb,
lib/gigo/rchardet/gb2312prober.rb,
lib/gigo/rchardet/hebrewprober.rb,
lib/gigo/rchardet/latin1prober.rb,
lib/gigo/rchardet/charsetprober.rb,
lib/gigo/rchardet/langthaimodel.rb,
lib/gigo/rchardet/langgreekmodel.rb,
lib/gigo/rchardet/langhebrewmodel.rb,
lib/gigo/rchardet/mbcharsetprober.rb,
lib/gigo/rchardet/mbcsgroupprober.rb,
lib/gigo/rchardet/sbcharsetprober.rb,
lib/gigo/rchardet/sbcsgroupprober.rb,
lib/gigo/rchardet/chardistribution.rb,
lib/gigo/rchardet/langcyrillicmodel.rb,
lib/gigo/rchardet/universaldetector.rb,
lib/gigo/transcoders/active_support.rb,
lib/gigo/rchardet/charsetgroupprober.rb,
lib/gigo/rchardet/codingstatemachine.rb,
lib/gigo/rchardet/langbulgarianmodel.rb,
lib/gigo/rchardet/langhungarianmodel.rb

Overview

BEGIN LICENSE BLOCK ######################## The Original Code is Mozilla Communicator client code.

The Initial Developer of the Original Code is Netscape Communications Corporation. Portions created by the Initial Developer are Copyright © 1998 the Initial Developer. All Rights Reserved.

Contributor(s):

Jeff Hodges - port to Ruby
Mark Pilgrim - port to Python

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA END LICENSE BLOCK #########################

Defined Under Namespace

Modules: CharDet, Transcoders

Constant Summary collapse

VERSION =
"1.4.0"

Class Method Summary collapse

Class Method Details

.load(data, options = {}) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/gigo.rb', line 14

def self.load(data, options = {})
  return data if data.nil? || !data.acts_like?(:string)
  tcoders = options[:transcoders] || transcoders
  encoded_string = transcode(data, tcoders)
  return data if data.encoding == GIGO.encoding && data == encoded_string
  encoded_string
end