utf8_print | R Documentation |
Print a UTF-8 character object.
utf8_print(x, chars = NULL, quote = TRUE, na.print = NULL,
print.gap = NULL, right = FALSE, max = NULL,
names = NULL, rownames = NULL, escapes = NULL,
display = TRUE, style = TRUE, utf8 = NULL, ...)
x |
character object. |
chars |
integer scalar indicating the maximum number of
character units to display. Wide characters like emoji take
two character units; combining marks and default ignorables
take none. Longer strings get truncated and suffixed or prefixed
with an ellipsis ( |
quote |
logical scalar indicating whether to put surrounding
double-quotes ( |
na.print |
character string (or |
print.gap |
non-negative integer (or |
right |
logical scalar indicating whether to right-justify character strings. |
max |
non-negative integer (or |
names |
a character string specifying the display style for the (column) names, as an ANSI SGR parameter string. |
rownames |
a character string specifying the display style for the row names, as an ANSI SGR parameter string. |
escapes |
a character string specifying the display style for the backslash escapes, as an ANSI SGR parameter string. |
display |
logical scalar indicating whether to optimize the encoding for display, not byte-for-byte data transmission. |
style |
logical scalar indicating whether to apply ANSI
terminal escape codes to style the output. Ignored when
|
utf8 |
logical scalar indicating whether to optimize results
for a UTF-8 capable display, or |
... |
further arguments passed from other methods. Ignored. |
utf8_print
prints a character object after formatting it with
utf8_format
.
For ANSI terminal output (when output_ansi()
is TRUE
),
you can style the row and column names with the rownames
and
names
parameters, specifying an ANSI SGR parameter string; see
https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters.
The function returns x
invisibly.
utf8_format
.
# printing (assumes that output is capable of displaying Unicode 10.0.0)
print(intToUtf8(0x1F600 + 0:79)) # with default R print function
utf8_print(intToUtf8(0x1F600 + 0:79)) # with utf8_print, truncates line
utf8_print(intToUtf8(0x1F600 + 0:79), chars = 1000) # higher character limit
# in C locale, output ASCII (same results on all platforms)
oldlocale <- Sys.getlocale("LC_CTYPE")
invisible(Sys.setlocale("LC_CTYPE", "C")) # switch to C locale
utf8_print(intToUtf8(0x1F600 + 0:79))
invisible(Sys.setlocale("LC_CTYPE", oldlocale)) # switch back to old locale
# Mac and Linux only: style the names
# see https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters
utf8_print(matrix(as.character(1:20), 4, 5),
names = "1;4", rownames = "2;3")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.