It was actually a .rmd file so you can get the coloring of the bug report
in your text editor. I changed the format to .txt.

-Farid

On Sun, Aug 12, 2018 at 7:24 AM, Jeff Newmiller <jdnew...@dcn.davis.ca.us>
wrote:

> ... and read the Posting Guide... only a few file types will ever make it
> through the mailing list so repeatedly sending files not among those few
> types would just be frustrating for everyone.
>
> On August 11, 2018 4:51:43 PM PDT, Jim Lemon <drjimle...@gmail.com> wrote:
> >Hi Farid,
> >Whatever you attached has not gotten through.
> >
> >Jim
> >
> >On Sat, Aug 11, 2018 at 6:47 PM, Farid Ch <faridc...@gmail.com> wrote:
> >> Hi all,
> >>
> >> Please check the attached file.
> >>
> >> Thanks
> >> Farid
> >>
> >>
> >> ______________________________________________
> >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> >http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >
> >______________________________________________
> >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >https://stat.ethz.ch/mailman/listinfo/r-help
> >PLEASE do read the posting guide
> >http://www.R-project.org/posting-guide.html
> >and provide commented, minimal, self-contained, reproducible code.
>
> --
> Sent from my phone. Please excuse my brevity.
>
Write the text below with Farsi alphabet in a buffer and save it as a .r script

```{r}
letters_fa <- c('الف','ب','پ','ت','ث','ج','چ','ح','خ','ر','ز','د')
```

then try these lines to `source()` it:

```{r}
script <- "path/to/script.R"
file(script,
     encoding = "UTF-8") %>%
     readLines() # works fine

file(script,
     encoding = "UTF-8") %T>%
     source() %>% 
     close()   # works fine

source(script) # the Farsi letters in the environment are misrepresented

source(script,
       encoding = "UTF-8") # gives error
```

The last line throws error. I tried to debug it and I believe there is a bug in 
the `source()` function, in the following lines:

```{r}
loc <- utils::localeToCharset()[1L]
```

The error occurs at .Internal(parse( line....

```{r}
exprs <- if (!from_file) {
if (length(lines))
.Internal(parse(stdin(), n = -1, lines, "?",
           srcfile, encoding))
else expression()
}
else .Internal(parse(file, n = -1, NULL, "?", srcfile,
            encoding))
```

The verbatim error is:

> Error in source(script, encoding = "UTF-8") :
script.R:2:17: unexpected INCOMPLETE_STRING
1: #' @export
2: letters_fa <- c('
            ^

bug.report("source-script-file-that-contains-unicode-farsi-character",file="scripts/bug-source-unicode.rmd",package
 = "base")
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to