The source code of this function should be self-explanatory.

file_string(file)

Arguments

file

Path to a text file (should be encoded in UTF-8).

Value

A character string of text lines concatenated by '\n'.

Examples

xfun::file_string(system.file("DESCRIPTION", package = "xfun"))
#> Package: xfun
#> Type: Package
#> Title: Supporting Functions for Packages Maintained by 'Yihui Xie'
#> Version: 0.50
#> Authors@R: c(
#>   person("Yihui", "Xie", role = c("aut", "cre", "cph"), email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666")),
#>   person("Wush", "Wu", role = "ctb"),
#>   person("Daijiang", "Li", role = "ctb"),
#>   person("Xianying", "Tan", role = "ctb"),
#>   person("Salim", "Brüggemann", role = "ctb", email = "salim-b@pm.me", comment = c(ORCID = "0000-0002-5329-5987")),
#>   person("Christophe", "Dervieux", role = "ctb"),
#>   person()
#>   )
#> Description: Miscellaneous functions commonly used in other packages maintained by 'Yihui Xie'.
#> Depends: R (>= 3.2.0)
#> Imports: grDevices, stats, tools
#> Suggests: testit, parallel, codetools, methods, rstudioapi, tinytex (>=
#>         0.30), mime, litedown (>= 0.4), commonmark, knitr (>= 1.47),
#>         remotes, pak, rhub, renv, curl, xml2, jsonlite, magick, yaml,
#>         qs, rmarkdown
#> License: MIT + file LICENSE
#> URL: https://github.com/yihui/xfun
#> BugReports: https://github.com/yihui/xfun/issues
#> Encoding: UTF-8
#> RoxygenNote: 7.3.2
#> VignetteBuilder: litedown
#> Roxygen: list(markdown = TRUE)
#> Author: Yihui Xie [aut, cre, cph] (<https://orcid.org/0000-0003-0645-5666>),
#>   Wush Wu [ctb],
#>   Daijiang Li [ctb],
#>   Xianying Tan [ctb],
#>   Salim Brüggemann [ctb] (<https://orcid.org/0000-0002-5329-5987>),
#>   Christophe Dervieux [ctb]
#> Maintainer: Yihui Xie <xie@yihui.name>
#> Built: R 4.4.1; x86_64-pc-linux-gnu; 2025-01-09 18:27:57 UTC; unix