Skip to content

Commit

Permalink
Merge pull request #60 from leoniedu/master
Browse files Browse the repository at this point in the history
file encoding issue when reading as raw
  • Loading branch information
wilsonfreitas committed Jun 19, 2023
2 parents 664beec + 8ba96df commit b0a66ed
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions R/rbcb_get_currencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ get_currency_list <- function() {
return(get("TEMP_FILE_CURRENCY_LIST", envir = .CACHE_ENV))
} else {
res <- get_valid_currency_list()
x <- http_gettext(res)

x <- http_gettext(res, encoding="windows-1252")
df <- read.table(text = x, sep = ";", header = TRUE, colClasses = "character")
names(df) <- c("code", "name", "symbol", "country_code", "country_name", "type", "exclusion_date")

Expand Down
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ http_poster <- function(url, body, encode = "form", verbose = getOption("rbcb_ve
http_gettext <- function(res, encoding = "UTF-8", as = "raw") {
x <- content(res, as = as, encoding = encoding)
if (as == "raw") {
rawToChar(x)
iconv(rawToChar(x),from=encoding)
} else {
x
}
Expand Down

0 comments on commit b0a66ed

Please sign in to comment.