[R-pkg-devel] ASCII code for Degree symbol °

Rafael H. M. Pereira r@|@@pere|r@@br @end|ng |rom gm@||@com
Mon Jan 24 13:49:00 CET 2022


Thank you Matt and Ivan. This is all much appreciated. The concern with
portability across OS is also very important! thanks again!

Rafael

On Mon, Jan 24, 2022 at 7:03 AM Matt Denwood <md using sund.ku.dk> wrote:

> Hi Rafael
>
> I find ?stringi::stri_escape_unicode to be extremely useful for generating
> \uxxxx escapes, for example:
>
> > stringi::stri_escape_unicode("°") |> cat("\n")
> \u00b0
>
> Which can be reversed (for checking) using:
>
> > stringi::stri_unescape_unicode("\u00b0") |> cat("\n")
> °
>
> This also works with non-ASCII characters embedded in longer sentences:
>
> > stringi::stri_escape_unicode("Åv — mærkelige tegn!") |> cat("\n")
> \u00c5v \u2014 m\u00e6rkelige tegn!
>
> > stringi::stri_unescape_unicode("\u00c5v \u2014 m\u00e6rkelige tegn!") |>
> cat("\n")
> Åv — mærkelige tegn!
>
> Big thanks to the authors of the stringi package if they are reading this!
>
> Cheers,
>
> Matt
>
>
> On 24/01/2022, 03:26, "R-package-devel on behalf of Rafael H. M. Pereira"
> <r-package-devel-bounces using r-project.org on behalf of
> rafa.pereira.br using gmail.com> wrote:
>
>     Thank you, dbosak01. This was really  really  helpful !
>
>     best wishes,
>     Rafael Pereira
>
>     On Sun, Jan 23, 2022 at 11:09 PM <dbosak01 using gmail.com> wrote:
>
>     > vec <- c("one", "two", "three°")
>     > vec
>     > # [1] "one"    "two"    "three°"
>     >
>     > vec1 <- gsub("[\xB0]", ".", vec)
>     > vec1
>     > # [1] "one"    "two"    "three."
>     >
>     > -----Original Message-----
>     > From: R-package-devel <r-package-devel-bounces using r-project.org> On
> Behalf
>     > Of Rafael H. M. Pereira
>     > Sent: Sunday, January 23, 2022 8:55 PM
>     > To: r-package-devel using r-project.org
>     > Subject: [R-pkg-devel] ASCII code for Degree symbol °
>     >
>     > Hi all.
>     >
>     > In one of the functions of my package (flightsbr), I have a vector
> with
>     > character strings where I need to replace the degree symbol ° with a
> point
>     > '.' So this is what I do:
>     >
>     > vec <- gsub("[°]", ".", vec)
>     >
>     > However, I keep getting this Warning from devtools::check():
>     >   Found the following file with non-ASCII characters:
>     >     utils.R
>     >   Portable packages must use only ASCII characters in their R code,
>     >   except perhaps in comments.
>     >   Use \uxxxx escapes for other characters.
>     >
>     > I assume there is a ASCII representation of °, but I cannot really
> find a
>     > way to do this using ASCII  characters. Any ideas?
>     >
>     > best,
>     > Rafael Pereira
>     >
>     >         [[alternative HTML version deleted]]
>     >
>     > ______________________________________________
>     > R-package-devel using r-project.org mailing list
>     >
> https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-package-devel&data=04%7C01%7Cmd%40sund.ku.dk%7Cb335bac4a0fa4a169dbb08d9dee0beed%7Ca3927f91cda14696af898c9f1ceffa91%7C0%7C0%7C637785879700256001%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=EdbzG%2BVYzo%2Bgw20O4GUAwDFVz2JK4AFVc7gAzScg7a8%3D&reserved=0
>     >
>     >
>
>         [[alternative HTML version deleted]]
>
>     ______________________________________________
>     R-package-devel using r-project.org mailing list
>
> https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-package-devel&data=04%7C01%7Cmd%40sund.ku.dk%7Cb335bac4a0fa4a169dbb08d9dee0beed%7Ca3927f91cda14696af898c9f1ceffa91%7C0%7C0%7C637785879700256001%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=EdbzG%2BVYzo%2Bgw20O4GUAwDFVz2JK4AFVc7gAzScg7a8%3D&reserved=0
>
>

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list