Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Encoding of retrieved messages #86

Closed
SimonCoulombe opened this issue Nov 7, 2017 · 2 comments
Closed

Encoding of retrieved messages #86

SimonCoulombe opened this issue Nov 7, 2017 · 2 comments
Labels
bug an unexpected problem or unintended behavior reprex needs a minimal reproducible example

Comments

@SimonCoulombe
Copy link

SimonCoulombe commented Nov 7, 2017

Hi Jim,

I am trying to retrieve messages and run some regexp on the content. I am retrieving the body of my message as follow:

my_message = message(id = "myid", format="full")
body(my_message)

The issue I have is that all the French characters are broken and replaced by funky symbols. Where can I set the encoding to fix this?

Fantastic package, thanks for it.

@SimonCoulombe
Copy link
Author

SimonCoulombe commented Nov 8, 2017

This works for me:

my_base64url_decode_to_char <- function(x) { iconv(rawToChar(base64decode(gsub("_", "/", gsub("-", "+", x)))), from="UTF-8", to="latin1") }

getAnywhere("base64url_decode_to_char")
unlockBinding("base64url_decode_to_char", getNamespace("gmailr"))
assign("base64url_decode_to_char", my_base64url_decode_to_char, getNamespace("gmailr"))

edit: this worked once. I have output to prove it... but now it doesnt.
When I run body() I now get the following error
Error in base64decode(gsub("_", "/", gsub("-", "+", x))) :
could not find function "base64decode"

edit 2: adding "base64enc::" fixes it.

my_base64url_decode_to_char <- function(x) { iconv(rawToChar(base64enc::base64decode(gsub("_", "/", gsub("-", "+", x)))), from="UTF-8", to="latin1") }

@jimhester jimhester added bug an unexpected problem or unintended behavior reprex needs a minimal reproducible example labels Aug 13, 2019
@jimhester
Copy link
Member

@SimonCoulombe if you are still running into this problem could you provide an example email object that shows the issue as an .Rds, using saveRDS(msg, "out.Rds").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior reprex needs a minimal reproducible example
Projects
None yet
Development

No branches or pull requests

2 participants