The R Project SVN R

Rev

Rev 59039 | Rev 84678 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 59039 Rev 61160
Line 36... Line 36...
36
\examples{
36
\examples{
37
x <- "fa\xE7ile"
37
x <- "fa\xE7ile"
38
encoded_text_to_latex(x, "latin1")
38
encoded_text_to_latex(x, "latin1")
39
\dontrun{
39
\dontrun{
40
## create a tex file to show the upper half of 8-bit charsets
40
## create a tex file to show the upper half of 8-bit charsets
41
x <- rawToChar(as.raw(160:255), multiple=TRUE)
41
x <- rawToChar(as.raw(160:255), multiple = TRUE)
42
(x <- matrix(x, ncol=16, byrow=TRUE))
42
(x <- matrix(x, ncol = 16, byrow = TRUE))
43
xx <- x
43
xx <- x
44
xx[] <- encoded_text_to_latex(x, "latin1") # or latin2 or latin9
44
xx[] <- encoded_text_to_latex(x, "latin1") # or latin2 or latin9
45
xx <- apply(xx, 1, paste, collapse="&")
45
xx <- apply(xx, 1, paste, collapse = "&")
46
con <- file("test-encoding.tex", "w")
46
con <- file("test-encoding.tex", "w")
47
header <- c(
47
header <- c(
48
"\\\\documentclass{article}",
48
"\\\\documentclass{article}",
49
"\\\\usepackage[T1]{fontenc}",
49
"\\\\usepackage[T1]{fontenc}",
50
"\\\\usepackage{Rd}",
50
"\\\\usepackage{Rd}",
Line 52... Line 52...
52
"\\\\HeaderA{test}{}{test}",
52
"\\\\HeaderA{test}{}{test}",
53
"\\\\begin{Details}\\relax",
53
"\\\\begin{Details}\\relax",
54
"\\\\Tabular{cccccccccccccccc}{")
54
"\\\\Tabular{cccccccccccccccc}{")
55
trailer <- c("}", "\\\\end{Details}", "\\\\end{document}")
55
trailer <- c("}", "\\\\end{Details}", "\\\\end{document}")
56
writeLines(header, con)
56
writeLines(header, con)
57
writeLines(paste(xx, "\\\\", sep=""), con)
57
writeLines(paste0(xx, "\\\\"), con)
58
writeLines(trailer, con)
58
writeLines(trailer, con)
59
close(con)
59
close(con)
60
## and some UTF_8 chars
60
## and some UTF_8 chars
61
x <- intToUtf8(as.integer(
61
x <- intToUtf8(as.integer(
62
    c(160:383,0x0192,0x02C6,0x02C7,0x02CA,0x02D8,
62
    c(160:383,0x0192,0x02C6,0x02C7,0x02CA,0x02D8,
63
      0x02D9, 0x02DD, 0x200C, 0x2018, 0x2019, 0x201C,
63
      0x02D9, 0x02DD, 0x200C, 0x2018, 0x2019, 0x201C,
64
      0x201D, 0x2020, 0x2022, 0x2026, 0x20AC)),
64
      0x201D, 0x2020, 0x2022, 0x2026, 0x20AC)),
65
               multiple=TRUE)
65
               multiple = TRUE)
66
x <- matrix(x, ncol=16, byrow=TRUE)
66
x <- matrix(x, ncol = 16, byrow = TRUE)
67
xx <- x
67
xx <- x
68
xx[] <- encoded_text_to_latex(x, "UTF-8")
68
xx[] <- encoded_text_to_latex(x, "UTF-8")
69
xx <- apply(xx, 1, paste, collapse="&")
69
xx <- apply(xx, 1, paste, collapse = "&")
70
con <- file("test-utf8.tex", "w")
70
con <- file("test-utf8.tex", "w")
71
writeLines(header, con)
71
writeLines(header, con)
72
writeLines(paste(xx, "\\\\", sep=""), con)
72
writeLines(paste(xx, "\\\\", sep = ""), con)
73
writeLines(trailer, con)
73
writeLines(trailer, con)
74
close(con)
74
close(con)
75
}}
75
}}
76
\keyword{utilities}
76
\keyword{utilities}