You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ioslides_presentation "Invalid UTF-8 stream" error with #134
The error appears to be caused by pandoc.table returning for the first column header, as removing eliminates the error. Below is an Rmd file that can be used to reproduce the error message. The same error message occurs when using the Knit HTML button in RStudio.
My Rmd file consists only of the code shown in my first post above. Interestingly, if I change to output: beamer_presentation, I don't receive any errors. The problem is consistently reproducible with output: ioslides_presentation on my machine, so if there is anything else I can provide, let me know.
I also use kable but in this case was trying to leverage the row and column emphasize functionality of pandoc.table.
This question may provide more insight. Could the default text encoding on my machine be causing this problem? I'm using RStudio to execute scripts, and under Tools->General ->Default text encoding I see [Ask], but clicking Change lists ISO-8859-1 as the System Default.
Getting closer here, I think the problem may be related to the encoding used to save the Rmd file (I'm currently using the default RStudio settings described above). When I open the Rmd file in Notepad++, the Encoding menu lists it as ANSI. Using Notepad++, if I choose Encoding->Covert to UTF-8 and re-save the file, render runs with only a warning. The resulting html file is missing a title slide, but I believe this is due to a BOM () being added to the file as part of the conversion. I see the following html where the title slide should be:
I think you are on the right track. You should re-save the Rmd file with the UTF-8 encoding (menu File > Save with encoding). I also recommend you to change your default text encoding to UTF-8.
I'll see if I can reproduce the problem with your text encoding and fix it. Thanks!
Same Invalid UTF-8 stream error if I save as UTF-8 via RStudio. Only way I've been able to get the file to run is if I convert to UTF-8 via Notepad++ or Notepad. Both conversion processes appear to add  to the beginning of the file.
I can confirm the issue with ES.AR locale (Spanish_Argentina.1252).
My guess is that this in a pandoc issue. I tried and got the same error with other computers at work. However, when I raised the issue with the pandoc team they couldn't reproduce it. See jgm/pandoc#1634
@dmurdoch Thanks for reporting this. We've seen issues with UTF-8 characters and ioslides previously but this was related to the use of unicode characters (which pandoc doesn't like when passed through a custom lua markdown renderer like the one we use with ioslides). Your example however appears to only include ascii characters. We'll investigate and hopefully figure out the root cause soon.
@dmurdoch I spent some time looking into this. It turns out that this is indeed just another manifestation of the non-ASCII character problem; when the citations are injected this content enters the document:
The dashes are en dashes (not hyphens), which are not ASCII, and are translated to this internal Pandoc representation (note the \8212 representation for the en dashes):
To the best of my knowledge there's nothing we can do on the rmarkdown side to fix this. We tried a bunch of different input document encodings with and without BOMs; the problem seems not to be in the processing of the input document (which in this case doesn't even contain the offending characters) but in Pandoc's internal handoff from its native encoding format to its Lua interpreter, over which we don't have control.
As a workaround until the underlying Pandoc issue is fixed (and this does seem to be jgm/pandoc#1634), you could use a CSL that doesn't write en dashes to the stream. For instance, this works for me, via small.csl from here:
The dashes are en dashes (not hyphens), which are not ASCII, and are
translated to this internal Pandoc representation (note the |\8212|
representation for the en dashes):
To the best of my knowledge there's nothing we can do on the rmarkdown
side to fix this. We tried a bunch of different input document encodings
with and without BOMs; the problem seems not to be in the processing of
the input document (which in this case doesn't even contain the
offending characters) but in Pandoc's internal handoff from its native
encoding format to its Lua interpreter, over which we don't have control.
Activity
yihui commentedon Jun 21, 2014
I cannot reproduce the problem with R 3.1.0 under Windows (from your pandoc.exe I guess you were using Windows). Please report your session info:
jrowen commentedon Jun 21, 2014
Below is the my session info and the full output from rendering the markdown document. Let me know if there is anything else I can provide.
Output from
sessionInfo():Output from
render():yihui commentedon Jun 26, 2014
Sorry, I really cannot reproduce it with exactly the same environment as yours. Can you send me your Rmd file by email? yihui[at]rstudio.com
yihui commentedon Jun 26, 2014
BTW, if all you want is a simple table, you can also try
knitr::kable(m)instead ofpandoc.table(m).jrowen commentedon Jun 27, 2014
My Rmd file consists only of the code shown in my first post above. Interestingly, if I change to
output: beamer_presentation, I don't receive any errors. The problem is consistently reproducible withoutput: ioslides_presentationon my machine, so if there is anything else I can provide, let me know.I also use
kablebut in this case was trying to leverage the row and column emphasize functionality ofpandoc.table.This question may provide more insight. Could the default text encoding on my machine be causing this problem? I'm using RStudio to execute scripts, and under Tools->General ->Default text encoding I see [Ask], but clicking Change lists ISO-8859-1 as the System Default.
Below is the raw
utf8.mdandknit.mddata.jrowen commentedon Jun 27, 2014
Getting closer here, I think the problem may be related to the encoding used to save the Rmd file (I'm currently using the default RStudio settings described above). When I open the Rmd file in Notepad++, the Encoding menu lists it as ANSI. Using Notepad++, if I choose Encoding->Covert to UTF-8 and re-save the file,
renderruns with only a warning. The resulting html file is missing a title slide, but I believe this is due to a BOM () being added to the file as part of the conversion. I see the following html where the title slide should be:yihui commentedon Jun 27, 2014
I think you are on the right track. You should re-save the Rmd file with the UTF-8 encoding (menu
File > Save with encoding). I also recommend you to change your default text encoding to UTF-8.I'll see if I can reproduce the problem with your text encoding and fix it. Thanks!
jrowen commentedon Jun 27, 2014
Same
Invalid UTF-8 streamerror if I save as UTF-8 via RStudio. Only way I've been able to get the file to run is if I convert to UTF-8 via Notepad++ or Notepad. Both conversion processes appear to add  to the beginning of the file.yihui commentedon Jun 27, 2014
Can Notepad++ convert the encoding to UTF-8 without the BOM?
Actually I'm a little surprised that the encoding matters here, since everything is pure ASCII, including
.jrowen commentedon Jun 27, 2014
Yes, it does have the Convert to UTF-8 without BOM option, but using it also yields the original
Invalid UTF-8 streamerror.yihui commentedon Aug 31, 2014
@jrowen Although it is unlikely to fix your problem, can you test the current development version of knitr (1.6.15) and see if the error persists?
jrowen commentedon Sep 2, 2014
Running into the same error with
(actually testedknitr1.6.16).yihui commentedon Sep 2, 2014
Hmm. I really cannot reproduce this problem. I think I have to leave it to other people in the team.
lselzer commentedon Sep 18, 2014
I tried to reproduce this issue and I couldn't.
yihui commentedon Sep 18, 2014
@lselzer Thanks for your help!
dmurdoch commentedon Apr 17, 2015
I get a similar error. It appears my minimal example is as follows:
minimal.Rmd:
with reflist.bib:
Running in Windows in a US locale, I get the following output messages when I try to compile:
lselzer commentedon Apr 17, 2015
I can confirm the issue with ES.AR locale (Spanish_Argentina.1252).
My guess is that this in a pandoc issue. I tried and got the same error with other computers at work. However, when I raised the issue with the pandoc team they couldn't reproduce it. See
jgm/pandoc#1634
jjallaire commentedon Apr 17, 2015
@dmurdoch Thanks for reporting this. We've seen issues with UTF-8 characters and ioslides previously but this was related to the use of unicode characters (which pandoc doesn't like when passed through a custom lua markdown renderer like the one we use with ioslides). Your example however appears to only include ascii characters. We'll investigate and hopefully figure out the root cause soon.
jmcphers commentedon Apr 20, 2015
@dmurdoch I spent some time looking into this. It turns out that this is indeed just another manifestation of the non-ASCII character problem; when the citations are injected this content enters the document:
———. 2014b. Shiny: Web Application Framework for R. http://shiny.rstudio.com.
The dashes are en dashes (not hyphens), which are not ASCII, and are translated to this internal Pandoc representation (note the
\8212representation for the en dashes):To the best of my knowledge there's nothing we can do on the rmarkdown side to fix this. We tried a bunch of different input document encodings with and without BOMs; the problem seems not to be in the processing of the input document (which in this case doesn't even contain the offending characters) but in Pandoc's internal handoff from its native encoding format to its Lua interpreter, over which we don't have control.
As a workaround until the underlying Pandoc issue is fixed (and this does seem to be jgm/pandoc#1634), you could use a CSL that doesn't write en dashes to the stream. For instance, this works for me, via small.csl from here:
jmcphers commentedon Apr 20, 2015
Filed an updated bug for Pandoc here: jgm/pandoc#2101
dmurdoch commentedon Apr 20, 2015
On 20/04/2015 4:20 PM, Jonathan wrote:
Thanks, this is really helpful. I'm on the road right now and can't
check that it works, but it certainly looks like it should.
Duncan Murdoch
github-actions commentedon Nov 3, 2020
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.
Only do the chcp setting with Pandoc before 2.0