Package inputenc Error: Unicode char \u8 in RStudio Package inputenc Error: Unicode char \u8 in RStudio r r

Package inputenc Error: Unicode char \u8 in RStudio


Given the almost identical error message, I tried following @scoa's suggestion, but putting that line in the YAML header did not change the error, so for whatever reason, Knitr wasn't looking there to determine the LaTex engine. However, next to the "Knit PDF" button in the control bar is a settings menu that allows you to specify the LaTex ending in the "Advanced" pane. This solved the problem for me. It produces a slight variation on the suggestion above, modifying the YAML header thus:

  output:     pdf_document:         latex_engine: xelatex

I can see that @scoa may have assumed the YAML output was already formatted this way, but what I was missing was the colon after 'pdf_document'. Using the settings dialogue created the proper syntax in the header.

RStudio version 0.99.896, knitr version 1.12.3.

enter image description here


Here is a less technical solution but it worked for me when everything else didn't. Try deleting (after copying your code elsewhere) parts of your file and then kniting it. Then by process of elimination you will be able to narrow it down to the character/s that are causing the problem. Keep in mind there may be multiple occurrences of the problem. To make it easier to find the character the error message gave me the utf code of the character and I was able to look up what it was. Apparently there was a special 'fi' character used five times in the text I copied and pasted from so I looked for and replaced them with a normal 'fi'.


I know I am a bit late for this, but I just had almost the same error (minus the pandoc part).

The problem was that I copy pasted a sentence from wikipedia, which had a dash character which was not utf8 formatted. I replaced the dash and it worked.

Latex fails (with an encoding error) to create a pdf if there are "special" characters in your document, like incorrect whitespace/newline characters, or characters with accents. An easy way to check copy-pasted text is to first paste it into a very basic text editor, like nedit.