Skip to content

Commit

Permalink
change of decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
prcwiek committed Oct 25, 2023
1 parent 2245829 commit 8255df1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions R/metar_get.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ metar_get <- function(airport = "EPWA"){
return(invisible(NULL))
}

metar <- stringr::str_extract(httr::content(myfile, as = "text", encoding = "UTF-8"), pattern = "<code>[:print:]+</code>")
metar <- stringr::str_replace(metar, "<code>", "")
metar <- stringr::str_replace(metar, "</code>", "")
metar <- httr::content(myfile, as = "text", encoding = "UTF-8")
metar <- stringr::str_replace(metar, "\n", "")
metar[is.na(metar)] <- "No METAR found!"
if (metar == "") {
metar <- "No METAR found!"
}
message("Don't use for flight planning or navigation!")
metar
}

0 comments on commit 8255df1

Please sign in to comment.