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
[R-pkg-devel] ASCII code for Degree symbol °
7 messages · Avraham Adler, dbos@k01 m@iii@g oii gm@ii@com, Rafael Pereira +2 more
https://theasciicode.com.ar/extended-ascii-code/degree-symbol-ascii-code-248.html On Mon, Jan 24, 2022 at 1:55 AM Rafael H. M. Pereira
<rafa.pereira.br at gmail.com> wrote:
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 at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel
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 at r-project.org> On Behalf Of Rafael H. M. Pereira
Sent: Sunday, January 23, 2022 8:55 PM
To: r-package-devel at 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
______________________________________________
R-package-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel
Thank you, dbosak01. This was really really helpful ! best wishes, Rafael Pereira
On Sun, Jan 23, 2022 at 11:09 PM <dbosak01 at 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 at r-project.org> On Behalf
Of Rafael H. M. Pereira
Sent: Sunday, January 23, 2022 8:55 PM
To: r-package-devel at 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 at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel
On Sun, 23 Jan 2022 21:09:09 -0500
<dbosak01 at gmail.com> wrote:
vec1 <- gsub("[\xB0]", ".", vec)
A great degree of care is needed with this.
Encoding('\xB0') is "unknown", i.e. \xXX escape codes are assumed to be
bytes in your native system encoding. On GNU/Linux and other systems
where native encoding is UTF-8 (and not Latin-1 or an ANSI code page),
'\xB0' is an invalid byte sequence, not a degree symbol:
'\xB0' == '?'
# [1] FALSE
On the other hand, the code point for ? is also U+00B0:
as.hexmode(utf8ToInt('?'))
# [1] "b0"
'\ub0'
# [1] "?"
The difference is that Encoding('\ub0') is "UTF-8" and is therefore
portable between systems with different native encodings.
Best regards, Ivan
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 at r-project.org on behalf of rafa.pereira.br at 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 at 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 at r-project.org> On Behalf
> Of Rafael H. M. Pereira
> Sent: Sunday, January 23, 2022 8:55 PM
> To: r-package-devel at 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 at 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
>
>
______________________________________________
R-package-devel at 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
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 at 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 at r-project.org on behalf of
rafa.pereira.br at 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 at 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 at r-project.org> On
Behalf
> Of Rafael H. M. Pereira
> Sent: Sunday, January 23, 2022 8:55 PM
> To: r-package-devel at 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 at 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 at 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