Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UTF-8 chars in Yaml header rendered wrong #450

Open
hrafnkelle opened this issue Jul 10, 2015 · 17 comments
Open

UTF-8 chars in Yaml header rendered wrong #450

hrafnkelle opened this issue Jul 10, 2015 · 17 comments

Comments

@hrafnkelle
Copy link

If I write my name in the author: field in the YAML header it gets rendered wrong in the title slide.

If I copy/paste the same text into a slide, its rendered correctly.

From title slide
image

From a regular slide
image

@bbTomas
Copy link

bbTomas commented Dec 6, 2015

Hello, +1 for the repair, please.
I have created several study materials for my students in the beginning of 2015 and now, if I want to make a small change, it is a problem with international characters (UTF-8) in the title page.
In previous version of slidify, it worked perfectly. But with the new stringr library, the previous version of slidify does not work.
I really like the quiz widget, that is why I use slidify.
Thanks,
Tomas

@ramnathv
Copy link
Owner

ramnathv commented Dec 6, 2015

Are you not able to use the latest version of slidify which is compatible with the new stringr?

@bbTomas
Copy link

bbTomas commented Dec 7, 2015

The latest version of slidify with the new stringr works, but the title page has incorrectly rendered international characters, so I have to manually edit the .html file. I have to do this because my name contains international characters :-)

There is only a problem with the title page, it looks like it does not get UTF-8 encoding from the YAML section, instead of this, it translate it as a simple ANSI encoding.

Following pages work perfectly.

@ramnathv
Copy link
Owner

ramnathv commented Dec 7, 2015

So did the title page work correctly with international characters previously? I am trying to figure out if this is a regression in slidify or one of its supporting dependencies.

@bbTomas
Copy link

bbTomas commented Dec 8, 2015

Yes, it worked perfectly with the previous version. See comparison of two versions with sessionInfo()

The problem is with the newest version ("Teorie signálů" renders "Teorie signálĹŻ" and "Tomáš Bořil" renders "Tomáš BoĹ™il"

sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=Czech_Czech Republic.1250  LC_CTYPE=Czech_Czech Republic.1250    LC_MONETARY=Czech_Czech Republic.1250 LC_NUMERIC=C                         
[5] LC_TIME=Czech_Czech Republic.1250    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] slidify_0.5

loaded via a namespace (and not attached):
[1] magrittr_1.5   markdown_0.7.7 tools_3.2.2    whisker_0.3-2  yaml_2.1.13    stringi_1.0-1  knitr_1.11     stringr_1.0.0 

The previous version renders everything ok.

> sessionInfo()
R version 3.1.3 (2015-03-09)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=Czech_Czech Republic.1250  LC_CTYPE=Czech_Czech Republic.1250    LC_MONETARY=Czech_Czech Republic.1250 LC_NUMERIC=C                         
[5] LC_TIME=Czech_Czech Republic.1250    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] slidify_0.4.5

loaded via a namespace (and not attached):
[1] knitr_1.10.5   markdown_0.7.7 stringr_0.6.2  tools_3.1.3    whisker_0.3-2  yaml_2.1.13  

@ramnathv
Copy link
Owner

ramnathv commented Dec 8, 2015

Are you running slidify from the R console, or using the knit button inside of RStudio?

@bbTomas
Copy link

bbTomas commented Dec 8, 2015

From R console.

library(slidify)
slidify("index.Rmd")

But it is the same with the 'Knit HTML' button.

The YAML is as follows:

---
title       : Teorie signálů
subtitle    : 
author      : Tomáš Bořil
job         : 
framework   : io2012        # {io2012, html5slides, shower, dzslides, ...}
highlighter : highlight.js  # {highlight.js, prettify, highlight}
hitheme     : tomorrow      # 
widgets     : []            # {mathjax, quiz, bootstrap}
mode        : selfcontained # {standalone, draft}
knit        : slidify::knit2slides
---

@ramnathv
Copy link
Owner

ramnathv commented Dec 8, 2015

Weird, it seems to work correctly for me.

screen shot 2015-12-07 at 4 56 14 pm

Here is my sessionInfo()

R version 3.1.3 (2015-03-09)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.9.4 (Mavericks)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] devtools_1.9.1

loaded via a namespace (and not attached):
 [1] digest_0.6.8     htmltools_0.2.9  httpuv_1.3.3     memoise_0.2.1    mime_0.4         Rcpp_0.12.2     
 [7] rmarkdown_0.8.1  rsconnect_0.3.80 servr_0.2        tools_3.1.3      yaml_2.1.13    

@bbTomas
Copy link

bbTomas commented Dec 8, 2015

Well, could it be a problem of the locale? You have 'UTF-8', I have 1250 (which is 8 bit CP1250).
If I try to set, I get an error because my OS does not support that

Sys.setlocale("LC_ALL", 'en_US.UTF8')
Warning message:
In Sys.setlocale("LC_ALL", "en_US.UTF8") :
  OS reports request to set locale to "en_US.UTF8" cannot be honored

@bbTomas
Copy link

bbTomas commented Dec 8, 2015

It must be the problem with the locale encoding. I have converted the source file to CP1250 encoding and the title page works! But the following pages are distorted (because they expect UTF-8 and they get CP1250).
It is a complicated case :-/

@slavakx
Copy link

slavakx commented Dec 14, 2015

I have the same issue with the german locale...

@ramnathv
Copy link
Owner

Let me update the fix-encode branch with the latest commits to the master, so that you can test if encoding works correctly. Once that is confirmed, I can merge it back into the master.

@slavakx
Copy link

slavakx commented Dec 15, 2015

My locale is:

"LC_COLLATE=German_Germany.1252;LC_CTYPE=German_Germany.1252;LC_MONETARY=German_Germany.1252;LC_NUMERIC=C;LC_TIME=German_Germany.1252"

I did the following experiment:

  1. Created an Rmd page with default encoding (Windows-1252)
  2. In the title I wrote something with german umlauts
  3. In the R chunk of one of the slides I created a string variable with german letters
  4. Compiled

Outcome: The title page shows german correctly, the slide - not. When I changed a charset from UTF-8 to latin1 in the index.html the results were the opposite: The title didn't show correctly, the Slide did.

In the second experiment I saved the Rmd page in UTF-8
The Slides showed correctly but the Title was incorrect (changing to latin1 didn't help either)

@JoseAntonioOrtega
Copy link

I have the same experience with Spanish characters (á,é,í,ó,ú, ...). They show all right in all pages except for the title page. My locale

locale:
[1] LC_COLLATE=Spanish_Spain.1252 LC_CTYPE=Spanish_Spain.1252
[3] LC_MONETARY=Spanish_Spain.1252 LC_NUMERIC=C
[5] LC_TIME=Spanish_Spain.1252

@ManuelZ
Copy link

ManuelZ commented Jan 26, 2016

My title Slide is showing spanish characters correctly. My others slides don't show them correctly.

sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=Spanish_Peru.1252 LC_CTYPE=Spanish_Peru.1252 LC_MONETARY=Spanish_Peru.1252 LC_NUMERIC=C
[5] LC_TIME=Spanish_Peru.1252


title : Sesión 02
subtitle : Análisis de exportaciones de Latinoamérica
author : Manuel
job : Versión 01 - 27 de enero del 2016
framework : io2012 # {io2012, html5slides, shower, dzslides, ...}
highlighter : highlight.js # {highlight.js, prettify, highlight}
hitheme : tomorrow #
widgets : [] # {mathjax, quiz, bootstrap}
mode : selfcontained # {standalone, draft}
knit : slidify::knit2slides

@bbTomas
Copy link

bbTomas commented Apr 10, 2016

I have found a "solution". I have downloaded sources of old version of slidify (0.4.5) and stringr (0.6.2) and joined them together into one package called slidify 0.4.5-7. And it works!

You can download this old version (0.4.5-7) as follows

devtools::install_github("bbTomas/slidify")
devtools::install_github("bbTomas/slidifyLibraries")

Then, you can use it

library(slidify)
slidify("your-file.Rmd")

I do not know what is the change in stringr package but the new version 1.0.0 causes the problem with UTF-8 charecters in YAML when using international (not 'en_US.UTF8') locale.

Versions used:
Slidify 0.4.5: f7290bd
Stringr 0.6.2: https://github.com/hadley/stringr/tree/16744e1ae5ccda72d65fc1eeaeb54fae90a87a13

@GegznaV
Copy link

GegznaV commented Oct 5, 2016

I think #482 suggest a solution: to add missing encoding="UTF-8" in function read_file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants