Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Track the exact place of a not encoded character in an R script file

Tags:

r

encoding

more a tip question that can save lots of time in many cases. I have a script.R file which I try to save and get the error:

Not all of the characters in ~/folder/script.R could be encoded using ASCII. To save using a different encoding, choose "File | Save with Encoding..." from the main menu.

I was working on this file for months and today I was editing like crazy my code and got this error for the first time, so obviously I inserted a character that can not be encoded while I was working today.

My question is, can I track and find this specific character and where exactly in the document is?

There are about 1000 lines in my code and it's almost impossible to manually search it.

like image 1000
Kwnwps Avatar asked Feb 09 '23 01:02

Kwnwps


1 Answers

Use tools::showNonASCIIfile() to spot the non-ascii.

like image 169
Marcin Kosiński Avatar answered Feb 11 '23 14:02

Marcin Kosiński