In 14.6.2, where the issue of encoding non-English characters, the example code does not return the expected results.
The example code is as follows:
x1 <- "text\nEl Ni\xf1o was particularly bad this year"
read_csv(x1)$text
#> [1] "El Ni\xf1o was particularly bad this year"
x2 <- "text\n\x82\xb1\x82\xf1\x82\xc9\x82\xbf\x82\xcd"
read_csv(x2)$text
#> [1] "\x82\xb1\x82\xf1\x82ɂ\xbf\x82\xcd"
read_csv(x1, locale = locale(encoding = "Latin1"))$text
#> [1] "El Niño was particularly bad this year"
read_csv(x2, locale = locale(encoding = "Shift-JIS"))$text
#> [1] "こんにちは"
When I run the same code with R 4.3.2, I get the following errors.
library(tidyverse)
x1 <- "text\nEl Ni\xf1o was particularly bad this year"
read_csv(x1)$text
#> Warning in grepl("\n", path): unable to translate 'text
#> El Ni<f1>o was particularly bad this year' to a wide string
#> Warning in grepl("\n", path): input string 1 is invalid
#> Warning in grepl("^((http|ftp)s?|sftp)://", path): unable to translate 'text
#> El Ni<f1>o was particularly bad this year' to a wide string
#> Warning in grepl("^((http|ftp)s?|sftp)://", path): input string 1 is invalid
#> Error in basename(path): file name conversion problem -- name too long?
x2 <- "text\n\x82\xb1\x82\xf1\x82\xc9\x82\xbf\x82\xcd"
read_csv(x2)$text
#> Warning in grepl("\n", path): unable to translate 'text
#> <82><b1><82><f1><82>ɂ<bf><82><cd>' to a wide string
#> Warning in grepl("\n", path): input string 1 is invalid
#> Warning in grepl("^((http|ftp)s?|sftp)://", path): unable to translate 'text
#> <82><b1><82><f1><82>ɂ<bf><82><cd>' to a wide string
#> Warning in grepl("^((http|ftp)s?|sftp)://", path): input string 1 is invalid
#> Error in basename(path): file name conversion problem -- name too long?
read_csv(x1, locale = locale(encoding = "Latin1"))$text
#> Warning in grepl("\n", path): unable to translate 'text
#> El Ni<f1>o was particularly bad this year' to a wide string
#> Warning in grepl("\n", path): input string 1 is invalid
#> Warning in grepl("^((http|ftp)s?|sftp)://", path): unable to translate 'text
#> El Ni<f1>o was particularly bad this year' to a wide string
#> Warning in grepl("^((http|ftp)s?|sftp)://", path): input string 1 is invalid
#> Error in basename(path): file name conversion problem -- name too long?
read_csv(x2, locale = locale(encoding = "Shift-JIS"))$text
#> Warning in grepl("\n", path): unable to translate 'text
#> <82><b1><82><f1><82>ɂ<bf><82><cd>' to a wide string
#> Warning in grepl("\n", path): input string 1 is invalid
#> Warning in grepl("^((http|ftp)s?|sftp)://", path): unable to translate 'text
#> <82><b1><82><f1><82>ɂ<bf><82><cd>' to a wide string
#> Warning in grepl("^((http|ftp)s?|sftp)://", path): input string 1 is invalid
In 14.6.2, where the issue of encoding non-English characters, the example code does not return the expected results.
The example code is as follows:
When I run the same code with R 4.3.2, I get the following errors.
Created on 2023-11-15 with reprex v2.0.2