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")