From 0afd1649c187390c19f2adcba9bba2edff7ae597 Mon Sep 17 00:00:00 2001 From: Yihui Xie Date: Tue, 22 Sep 2015 00:15:21 -0500 Subject: [PATCH] textConnection() can be lossy; use an anonymous file connection instead to preserve UTF-8 characters --- R/shinyui.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/shinyui.R b/R/shinyui.R index 163395b09..74202c5d5 100644 --- a/R/shinyui.R +++ b/R/shinyui.R @@ -106,7 +106,7 @@ uiHttpHandler <- function(ui, uiPattern = "^/$") { if (!isTRUE(grepl(uiPattern, req$PATH_INFO))) return(NULL) - textConn <- textConnection(NULL, "w", encoding = 'UTF-8') + textConn <- file(open = "w+", encoding = 'UTF-8') on.exit(close(textConn)) showcaseMode <- .globals$showcaseDefault @@ -127,7 +127,7 @@ uiHttpHandler <- function(ui, uiPattern = "^/$") { return(NULL) renderPage(uiValue, textConn, showcaseMode) - html <- paste(textConnectionValue(textConn), collapse='\n') + html <- paste(readLines(textConn, encoding = 'UTF-8'), collapse='\n') return(httpResponse(200, content=enc2utf8(html))) } }