<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,6 +1,6 @@
 Gem::Specification.new do |s|
 	s.name = %q{Html2Feedbooks}
-	s.version = '1.0.5'
+	s.version = '1.0.6'
 	s.date = %q{2009-04-28}
 	s.authors = [&quot;Benoit Larroque&quot;]
 	s.email = &quot;zeta dot ben at gmail dot com&quot;</diff>
      <filename>Html2Feedbooks.gemspec</filename>
    </modified>
    <modified>
      <diff>@@ -14,6 +14,7 @@ include HTML2FB
 options = {}
 options[:conf] = &quot;conf.yaml&quot;
 options[:preview] = true
+options[:conv] = true
 OptionParser.new do |opts|
 	opts.banner = &quot;Usage: html2fb [options] URL&quot;
 
@@ -23,6 +24,9 @@ OptionParser.new do |opts|
 	opts.on(&quot;-s&quot;, &quot;-s&quot;,&quot;Send to feedbooks&quot;) do |f|
 		options[:preview] = !f
 	end
+	opts.on(&quot;-nc&quot;, &quot;--no-conv&quot;,&quot;No charset conversion&quot;) do |f|
+		options[:conv] = !f
+	end
 end.parse!
 
 valid=false
@@ -40,7 +44,7 @@ while !valid
 	print &quot;URL : &quot; if entry.nil? || entry==''
 	entry=STDIN.readline.strip unless valid
 end
-conf=Conf.new(options[:conf])
+conf=Conf.new(options[:conf],options[:conv])
 content=Downloader.download(url)
 #puts content.size
 doc=Parser.new(conf).parse(content)</diff>
      <filename>bin/html2fb.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,13 +2,14 @@ require 'yaml'
 
 module HTML2FB
 	class Conf
-		def initialize(file)
+		def initialize(file,conv)
 			['','./',&quot;#{File.dirname(__FILE__)}/&quot;,&quot;#{File.dirname(__FILE__)}/../confs/&quot;].each do |p|
 				f=p+file
 				begin
 					if File.readable?(f) &amp;&amp; File.exists?(f)
 						@conf=File.open(f,'r'){|txt| YAML::load(txt)}
 						puts &quot;loaded config file : &quot;+f
+						@conf['conv']=conv
 						return 
 					end
 				rescue Exception =&gt; e </diff>
      <filename>lib/conf.rb</filename>
    </modified>
    <modified>
      <diff>@@ -15,6 +15,25 @@ module HTML2FB
 		def parse(txt)
 			puts &quot;Parsing HTML&quot;
 			pdoc=Hpricot(txt)
+			if @conf['conv']
+				mc=pdoc/'meta[@http-equiv=&quot;Content-Type&quot;]'
+				if mc.size&gt;0
+					charset=mc.first.attributes['content'].split(';').find do |s|
+						s.strip[0,7]=='charset'
+					end
+					unless charset.nil?
+						tc=charset.split('=').last.strip
+					end
+
+					unless tc.nil? 
+						puts &quot;Trying to convert source encoding from #{tc} to utf-8&quot;
+						require 'iconv'
+						pdoc=Hpricot(Iconv.conv('utf-8',tc.downcase,txt))
+
+					end
+
+				end
+			end
 			doc=Document.new
 			puts &quot;Removing garbage elements&quot;
 			remove_objs(pdoc)</diff>
      <filename>lib/parser.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>19636e81d03b2a0065f3afa29784714d86a3a2cb</id>
    </parent>
  </parents>
  <author>
    <name>Benoit Larroque</name>
    <email>zeta.ben@gmail.com</email>
  </author>
  <url>http://github.com/zetaben/Html2Feedbooks/commit/181fed872dd4f203b80204cd33035d2fbe31132e</url>
  <id>181fed872dd4f203b80204cd33035d2fbe31132e</id>
  <committed-date>2009-09-23T12:58:09-07:00</committed-date>
  <authored-date>2009-09-23T12:58:09-07:00</authored-date>
  <message>Adding an heuristic to autoconvert non UTF-8 files</message>
  <tree>326515934c2697dc3be28b025b27b1ec4ea53dc0</tree>
  <committer>
    <name>Benoit Larroque</name>
    <email>zeta.ben@gmail.com</email>
  </committer>
</commit>
