encoded(tools)
encoded()所属R语言包:tools
Translate non-ASCII Text to LaTeX Escapes
翻译非ASCII文本,LaTeX的逃逸
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Translate non-ASCII characters in text to LaTeX escape sequences.
翻译文本乳胶转义序列中的非ASCII字符。
用法----------Usage----------
encoded_text_to_latex(x,
encoding = c("latin1", "latin2", "latin9",
"UTF-8", "utf8"))
参数----------Arguments----------
参数:x
a character vector.
字符向量。
参数:encoding
the encoding to be assumed. "latin9" is officially ISO-8859-15 or Latin-9, but known as latin9 to LaTeX's inputenc package.
须承担的编码。 "latin9"正式ISO-8859-15-9拉丁美洲,但已知latin9的LaTeX的inputenc包。
Details
详情----------Details----------
Non-ASCII characters in x are replaced by an appropriate LaTeX escape sequence, or ? if there is no appropriate sequence.
x被替换为适当的乳胶转义序列,或者非ASCII字符?如果没有适当的顺序。
Even if there is an appropriate sequence, it may not be supported by the font in use. Hyphen is mapped to \-.
即使有适当的序列,它可能不支持在使用的字体。连字符被映射到\-。
值----------Value----------
A character vector of the same length as x.
一个x长度相同的特征向量。
参见----------See Also----------
iconv
iconv
举例----------Examples----------
x <- "fa\xE7ile"
encoded_text_to_latex(x, "latin1")
## Not run: [#无法运行:]
## create a tex file to show the upper half of 8-bit charsets[#创建一个tex文件的上半部分显示的8位字符集]
x <- rawToChar(as.raw(160:255), multiple=TRUE)
(x <- matrix(x, ncol=16, byrow=TRUE))
xx <- x
xx[] <- encoded_text_to_latex(x, "latin1") # or latin2 or latin9[或LATIN2或latin9]
xx <- apply(xx, 1, paste, collapse="&")
con <- file("test-encoding.tex", "w")
header <- c(
"\\documentclass{article}",
"\\usepackage[T1]{fontenc}",
"\\usepackage{Rd}",
"\\begin{document}",
"\\HeaderA{test}{}{test}",
"\\begin{Details}\relax",
"\\Tabular{cccccccccccccccc}{")
trailer <- c("}", "\\end{Details}", "\\end{document}")
writeLines(header, con)
writeLines(paste(xx, "\\", sep=""), con)
writeLines(trailer, con)
close(con)
## and some UTF_8 chars[#和一些UTF_8字符]
x <- intToUtf8(as.integer(
c(160:383,0x0192,0x02C6,0x02C7,0x02CA,0x02D8,
0x02D9, 0x02DD, 0x200C, 0x2018, 0x2019, 0x201C,
0x201D, 0x2020, 0x2022, 0x2026, 0x20AC)),
multiple=TRUE)
x <- matrix(x, ncol=16, byrow=TRUE)
xx <- x
xx[] <- encoded_text_to_latex(x, "UTF-8")
xx <- apply(xx, 1, paste, collapse="&")
con <- file("test-utf8.tex", "w")
writeLines(header, con)
writeLines(paste(xx, "\\", sep=""), con)
writeLines(trailer, con)
close(con)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|