File: read_utf8.Rd

package info (click to toggle)
r-cran-xfun 0.37%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 792 kB
  • sloc: ansic: 242; sh: 22; makefile: 2
file content (45 lines) | stat: -rw-r--r-- 1,501 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/io.R
\name{read_utf8}
\alias{read_utf8}
\alias{write_utf8}
\alias{append_utf8}
\alias{append_unique}
\title{Read / write files encoded in UTF-8}
\usage{
read_utf8(con, error = FALSE)

write_utf8(text, con, ...)

append_utf8(text, con, sort = TRUE)

append_unique(text, con, sort = function(x) base::sort(unique(x)))
}
\arguments{
\item{con}{A connection or a file path.}

\item{error}{Whether to signal an error when non-UTF8 characters are detected
(if \code{FALSE}, only a warning message is issued).}

\item{text}{A character vector (will be converted to UTF-8 via
\code{\link{enc2utf8}()}).}

\item{...}{Other arguments passed to \code{\link{writeLines}()} (except
\code{useBytes}, which is \code{TRUE} in \code{write_utf8()}).}

\item{sort}{Logical (\code{FALSE} means not to sort the content) or a
function to sort the content; \code{TRUE} is equivalent to
\code{base::sort}.}
}
\description{
Read or write files, assuming they are encoded in UTF-8. \code{read_utf8()}
is roughly \code{readLines(encoding = 'UTF-8')} (a warning will be issued if
non-UTF8 lines are found), and \code{write_utf8()} calls
\code{writeLines(enc2utf8(text), useBytes = TRUE)}.
}
\details{
The function \code{append_utf8()} appends UTF-8 content to a file or
connection based on \code{read_utf8()} and \code{write_utf8()}, and
optionally sort the content. The function \code{append_unique()} appends
unique lines to a file or connection.
}