File: astext.R

package info (click to toggle)
r-cran-sys 3.4.3-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 220 kB
  • sloc: ansic: 540; sh: 13; makefile: 2
file content (20 lines) | stat: -rw-r--r-- 528 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#' Convert Raw to Text
#'
#' Parses a raw vector as lines of text. This is similar to [charToRaw] but
#' splits output by (platform specific) linebreaks and allows for marking
#' output with a given encoding.
#'
#'
#' @export
#' @seealso [base::charToRaw]
#' @param x vector to be converted to text
#' @param ... parameters passed to [readLines] such as `encoding` or `n`
as_text <- function(x, ...){
  if(length(x)){
    con <- rawConnection(x)
    on.exit(close(con))
    readLines(con, ...)
  } else {
    character(0)
  }
}