Skip to content

Commit

Permalink
Fixing error Invalid UTF-8 characters with Hotmail
Browse files Browse the repository at this point in the history
  • Loading branch information
eofferma committed Dec 11, 2012
1 parent 22bdc4e commit a6375d4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/contacts/hotmail.rb
Expand Up @@ -63,9 +63,13 @@ def contacts(options = {})
url = URI.parse(contact_list_url)
contact_list_url = get_contact_list_url
data, resp, cookies, forward = get(contact_list_url, @cookies )

data.force_encoding('UTF-8')
@contacts = CSV.parse(data, {:headers => true, :col_sep => data[7]}).map do |row|
separator = data[7]
unless data.valid_encoding?
data = data.slice(2..-1).split("\u0000").join('')
separator = ','
end
@contacts = CSV.parse(data, {:headers => true, :col_sep => separator}).map do |row|
name = ""
name = row["First Name"] if !row["First Name"].nil?
name << " #{row["Last Name"]}" if !row["Last Name"].nil?
Expand Down

0 comments on commit a6375d4

Please sign in to comment.