class Object
Public Instance Methods
fixme_fetcher_read_utf8!( src )
click to toggle source
todo/fix: use/find better name? - e.g. Fetcher.read_utf8!() move out of global ns etc.
e.g. use Fetch.read_utf8!() e.g. throws exception on error read_blob!()
# File lib/pluto/tasks.rb, line 19 def fixme_fetcher_read_utf8!( src ) worker = Fetcher::Worker.new res = worker.get_response( src ) if res.code != '200' puts "sorry; failed to fetch >#{src} - HTTP #{res.code} - #{res.message}" exit 1 end ### # Note: Net::HTTP will NOT set encoding UTF-8 etc. # will be set to ASCII-8BIT == BINARY == Encoding Unknown; Raw Bytes Here # thus, set/force encoding to utf-8 txt = res.body.to_s txt = txt.force_encoding( Encoding::UTF_8 ) txt end