Skip to content

Commit

Permalink
let's read ui.R, server.R, README.md, and DESCRIPTION also with UTF-8
Browse files Browse the repository at this point in the history
the reason for this is that htmltools::htmlEscape() uses gsub(..., x, fixed =
TRUE), which does not work on Windows if x is encoded in UTF-8; fixed = TRUE
only works with the native encoding
  • Loading branch information
yihui committed Jul 10, 2014
1 parent bf270b9 commit 8063f66
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 5 additions & 5 deletions R/showcase.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ showcaseHead <- function() {
href="shared/shiny-showcase.css"),
if (file.exists(mdfile))
script(type="text/markdown", id="showcase-markdown-content",
paste(readLines(mdfile, warn = FALSE, encoding='UTF-8'), collapse="\n"))
paste(readUTF8(mdfile), collapse="\n"))
else ""
))

Expand Down Expand Up @@ -106,9 +106,7 @@ showcaseCodeTabs <- function(codeLicense) {
# we need to prevent the indentation of <code> ... </code>
HTML(format(tags$code(
class="language-r",
paste(readLines(file.path.ci(getwd(), rFile), warn=FALSE,
encoding='UTF-8'),
collapse="\n")
paste(readUTF8(file.path.ci(getwd(), rFile)), collapse="\n")
), indent = FALSE))))
})),
codeLicense))
Expand All @@ -122,7 +120,9 @@ showcaseAppInfo <- function() {
readmemd <- file.path.ci(getwd(), "Readme.md")
hasReadme <- file.exists(readmemd)
if (hasDesc) {
desc <- read.dcf(descfile)
con <- textConnection(readUTF8(descfile))
on.exit(close(con), add = TRUE)
desc <- read.dcf(con)
}
with(tags,
div(class="container-fluid shiny-code-container well",
Expand Down
5 changes: 5 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -916,3 +916,8 @@ setServerInfo <- function(...) {
infoOld[names(infoNew)] <- infoNew
.globals$serverInfo <- infoOld
}

readUTF8 <- function(file) {
x <- readLines(file, encoding = 'UTF-8', warn = FALSE)
enc2native(x)
}

0 comments on commit 8063f66

Please sign in to comment.