sQuote(base)
sQuote()所属R语言包:base
Quote Text
帖文
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Single or double quote text by combining with appropriate single or double left and right quotation marks.
结合适当的单人或双人左,右引号,单引号或双引号的文本。
用法----------Usage----------
sQuote(x)
dQuote(x)
参数----------Arguments----------
参数:x
an R object, to be coerced to a character vector.
一个R对象,被裹挟到一个字符向量。
Details
详情----------Details----------
The purpose of the functions is to provide a simple means of markup for quoting text to be used in the R output, e.g., in warnings or error messages.
功能的目的是为引用文本将用于在R输出,如警告或错误消息,提供一个简单的标记手段。
The choice of the appropriate quotation marks depends on both the locale and the available character sets. Older Unix/X11 fonts displayed the grave accent (ASCII code 0x60) and the apostrophe (0x27) in a way that they could also be used as matching open and close single quotation marks. Using modern fonts, or non-Unix systems, these characters no longer produce matching glyphs. Unicode provides left and right single quotation mark characters (U+2018 and U+2019); if Unicode markup cannot be assumed to be available, it seems good practice to use the apostrophe as a non-directional single quotation mark.
选择适当的引号取决于区域设置和可用的字符集。老年人UNIX/X11字体显示重音符号(ASCII码为0x60)和撇号(0x27的)中,他们也可以用来打开和关闭单引号匹配的方式。使用现代的字体,或者非Unix系统,这些字符不再产生匹配字形。 Unicode提供左,右单引号字符(ü2018和2019ü)如果Unicode的标记不能被认为是可用的,它似乎很好的做法,作为一种非定向的单引号使用撇号。
Similarly, Unicode has left and right double quotation mark characters (U+201C and U+201D); if only ASCII's typewriter characteristics can be employed, than the ASCII quotation mark (0x22) should be used as both the left and right double quotation mark.
同样,Unicode的有左,右双引号标记字符(ü+201Ç和ü+201ð);如果只有ASCII码的打字机特征可以被聘用,比“的ASCII引号标记(0x22)应被作为双方的左,右双引号标记使用。
Some other locales also have the directional quotation marks, notably on Windows. TeX uses grave and apostrophe for the directional single quotation marks, and doubled grave and doubled apostrophe for the directional double quotation marks.
也有一些其他的语言环境定向引号标记,特别是在Windows。 TeX的使用方向的单引号和撇号严重,翻了一番严重一倍定向双引号撇。
What rendering is used depend on the options setting for useFancyQuotes. If this is FALSE then the undirectional ASCII quotation style is used. If this is TRUE (the default), Unicode directional quotes are used are used where available (currently, UTF-8 locales on Unix-alikes and all Windows locales except C): if set to "UTF-8" UTF-8 markup is used (whatever the current locale). If set to "TeX", TeX-style markup is used. Finally, if this is set to a character vector of length four, the first two entries are used for beginning and ending single quotes and the second two for beginning and ending double quotes: this can be used to implement non-English quoting conventions such as the use of guillemets.
用什么渲染取决于options设置为useFancyQuotes。如果这是FALSE然后undirectional ASCII引号风格使用。如果这是TRUE(默认),Unicode方向引号的使用(目前,用于UTF-8语言环境在Unix相似者和所有的Windows区域设置除C):如果设置为"UTF-8"UTF-8标记(无论当前locale)。如果设置为"TeX",TEX-风格的标记。最后,如果设置一个长度为4的特征向量,前两个项目是用于开始和结束的开始和结束的双引号,单引号和第二个:这可以用来实现非英语引述如公约使用的guillemets。
Where fancy quotes are used, you should be aware that they may not be rendered correctly as not all fonts include the requisite glyphs: for example some have directional single quotes but not directional double quotes. This is particularly troublesome in Windows "Command Prompt" windows, which by default are set up to run in the so-called OEM codepage, which in most locales uses a different encoding from Windows. Further, if the codepage is changed (with chcp.exe, e.g. to 1252 in a Western European language), the default raster fonts do not support the directional quotes.
凡使用花哨的报价,你应该知道,他们可能无法正确呈现,因为不是所有的字体包括必要的字形,例如:一些有定向的单引号,但不定向的双引号。这是麻烦,特别是在Windows的“命令提示符”窗口,默认情况下,建立在所谓的OEM代码页,在大多数的语言环境中使用不同的编码从Windows运行。此外,如果改变的codepage(chcp.exe,在西欧语言如1252),默认的光栅字体不支持定向引号。
To work around this, the default for options("useFancyQuotes") is FALSE on Windows except for the Rgui console. There fancy quotes work with the default Courier New font and more elegantly with Lucida Console and standard the CJK fonts, but directional double quotes are missing in raster fonts such as Courier and FixedSys.
为了解决这个问题,默认options("useFancyQuotes")是FALSE除了Rgui控制台的Windows。有看中引号默认的宋体字体和更优雅的龙力控制台和标准CJK字体,但定向双引号光栅字体如Courier和使用Fixedsys失踪。
值----------Value----------
A character vector in the current locale's encoding.
一个在当前语言环境的编码字符向量。
参考文献----------References----------
http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html
参见----------See Also----------
Quotes for quoting R code.
引号报价R代码。
shQuote for quoting OS commands.
shQuote援引OS命令。
举例----------Examples----------
op <- options("useFancyQuotes")
paste("argument", sQuote("x"), "must be non-zero")
options(useFancyQuotes = FALSE)
cat("\ndistinguish plain", sQuote("single"), "and",
dQuote("double"), "quotes\n")
options(useFancyQuotes = TRUE)
cat("\ndistinguish fancy", sQuote("single"), "and",
dQuote("double"), "quotes\n")
options(useFancyQuotes = "TeX")
cat("\ndistinguish TeX", sQuote("single"), "and",
dQuote("double"), "quotes\n")
if(l10n_info()$`Latin-1`) {
options(useFancyQuotes = c("\xab", "\xbb", "\xbf", "?"))
cat("\n", sQuote("guillemet"), "and",
dQuote("Spanish question"), "styles\n")
} else if(l10n_info()$`UTF-8`) {
options(useFancyQuotes = c("\xc2\xab", "\xc2\xbb", "\xc2\xbf", "?"))
cat("\n", sQuote("guillemet"), "and",
dQuote("Spanish question"), "styles\n")
}
options(op)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|