Display of en dashes on shiny.io

36 views
Skip to first unread message

Philip Perrin

unread,
Nov 30, 2015, 9:52:28 AM11/30/15
to Shiny - Web Framework for R
Hi Everyone,

My application reads in a file (hierarchy.csv) and uses it as a lookup source to create two columns in a datatable.
This datatable is (i) rendered using the DT datatables function and (ii) exported it as results.csv

hierarchy.csv contains text with en dashes. When run locally these display correctly both in the rendered table and in results.csv.
However, when I publish the app to shiny.io, the en dashes are replaced with < 96 >. (I am using the same browser, Firefox, throughout)

I can get the en dashes to display in the rendered table on shiny.io by replacing them in hierarchy.csv with &#8211;
However, I then have this character code rather than en dashes in results.csv.

I suspect I need to specify encoding at some point but I am out of my depth in that regard.
How is the shiny.io server set up to deal with special characters?

Any suggestions?

Many thanks 

Philip

Andy Kipp

unread,
Nov 30, 2015, 10:05:22 AM11/30/15
to Philip Perrin, Shiny - Web Framework for R
Philip,

Do you know the encoding of your source file (hierarchy.csv)? Typically this should be UTF-8 encoded for maximum portability when running on shinyapps.io.

-Andy

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/7d3b56c9-2200-4954-9e20-0863eb80e6fd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Philip Perrin

unread,
Nov 30, 2015, 12:09:05 PM11/30/15
to Shiny - Web Framework for R, bwgan...@yahoo.co.uk
Hi Andy,

Thanks for you reply.
I saved hierarchy.csv from LibreOffice and selected Unicode UTF-8 encoding under "Edit filters"
After publishing on shiny.io, the en dashes (which are present as symbols not character code in the source file) are now correct in the table but in the results.csv I now get:

 Agrostis stolonifera – Potentilla anserina

So I specifed UTF in the downloadHandler function:

output$down = downloadHandler(
    filename = function() {paste("results_", analysis()$outName, sep = "")},
    content = function (file){write.csv(analysis()$fullTable, file, fileEncoding = "UTF-8")}
  )

But this doesn't change anything. Still, the issue now seems to be with encoding the output file rather than the shiny.io server. Any ideas?

Andy Kipp

unread,
Nov 30, 2015, 12:24:58 PM11/30/15
to Philip Perrin, Shiny - Web Framework for R
Hmm. Try using enc2uft8() to convert your analysis result to UTF-8 before converting it to CSV.

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages