Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

UTF-8 encoding issues with Ruby 2 #18

Open
alexchee opened this issue Apr 30, 2014 · 2 comments
Open

UTF-8 encoding issues with Ruby 2 #18

alexchee opened this issue Apr 30, 2014 · 2 comments

Comments

@alexchee
Copy link

I'm having an issue after upgrading to Ruby 2.1.0, with creating notes with binary data. I get a conversion error: Encoding::UndefinedConversionError: "\xC7" from ASCII-8BIT to UTF-8

Here's what I do to replicate with any pdf file:

client = EvernoteOAuth::Client.new(config)
pdf = File.open('test.pdf', 'rb') { |io| io.read }
file_name='test.pdf'
hexdigest = Digest::MD5.new.hexdigest(pdf)
data = Evernote::EDAM::Type::Data.new(:size=> pdf.size, :bodyHash=> hexdigest, :body=>pdf)
resource_attributes = Evernote::EDAM::Type::ResourceAttributes.new(:fileName => file_name)
resource = Evernote::EDAM::Type::Resource.new(:mime=>'application/pdf', :data=>data, :attributes=>resource_attributes)
content  = '<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">'+ %Q{ <en-note><en-media type='#{resource.mime}' hash='#{hexdigest}'/></en-note>}
note = Evernote::EDAM::Type::Note.new(:title=> title, :content=> content, :resources=>[resource], :notebookGuid=>'notebook_guid'])
client.note_store.createNote(note)

Here's the backtrace:

thrift-0.9.1/lib/thrift/bytes.rb:81:in `encode'
thrift-0.9.1/lib/thrift/bytes.rb:81:in `convert_to_utf8_byte_buffer'
thrift-0.9.1/lib/thrift/protocol/binary_protocol.rb:110:in `write_string'
thrift-0.9.1/lib/thrift/client.rb:35:in `write'
thrift-0.9.1/lib/thrift/client.rb:35:in `send_message'
evernote-thrift-1.25.1/lib/Evernote/EDAM/note_store.rb:678:in `send_createNote'
evernote-thrift-1.25.1/lib/Evernote/EDAM/note_store.rb:673:in `createNote'
evernote_oauth-0.2.2/lib/evernote_oauth/thrift_client_delegation.rb:11:in `method_missing'

This might be an evernote-thrift issue.

@vish315
Copy link

vish315 commented Oct 21, 2014

Were you able to resolve this issue?

@alexchee
Copy link
Author

No, I'm still waiting for an answer.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants