Skip to content

Commit

Permalink
Rename enc -> file.encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
Arni Magnusson committed Feb 21, 2019
1 parent 66fb011 commit 212387a
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 25 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export(dos2unix)
export(download)
export(draft.data)
export(draft.software)
export(enc)
export(file.encoding)
export(flr2taf)
export(latin1.to.utf8)
export(lim)
Expand Down
2 changes: 1 addition & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--------------------------------------------------------------------------------
icesTAF 2.2-0 (2019-02-20)
--------------------------------------------------------------------------------
o Added function enc() to examine file encoding. Added functions
o Added function file.encoding() to examine file encoding. Added functions
latin1.to.utf8() and utf8.to.latin1() to convert file encoding.

o Added function line.endings() to examine line endings.
Expand Down
11 changes: 6 additions & 5 deletions R/enc.R → R/file.encoding.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
#' @param file a filename.
#'
#' @return
#' \code{enc} returns \code{"latin1"}, \code{"UTF-8"}, \code{"unknown"}, or
#' \code{NA}.
#' \code{"latin1"}, \code{"UTF-8"}, \code{"unknown"}, or \code{NA}.
#'
#' This function requires the \command{file} shell command. If the
#' \command{file} utility is not found in the path, this function looks for it
Expand All @@ -25,19 +24,21 @@
#' \code{\link{latin1.to.utf8}} converts files from \verb{latin1} to
#' \verb{UTF-8} encoding.
#'
#' \code{\link{line.endings}} examines line endings.
#'
#' \code{\link{icesTAF-package}} gives an overview of the package.
#'
#' @examples
#' \dontrun{
#' file.base <- system.file(package="base", "DESCRIPTION")
#' file.nlme <- system.file(package="nlme", "DESCRIPTION")
#' enc(file.base) # ASCII
#' enc(file.nlme)
#' file.encoding(file.base) # ASCII
#' file.encoding(file.nlme)
#' }
#'
#' @export

enc <- function(file)
file.encoding <- function(file)
{
if(!file.exists(file))
stop("file not found")
Expand Down
2 changes: 1 addition & 1 deletion R/icesTAF-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
#' \code{\link{deps}} \tab list dependencies\cr
#' \code{\link{dos2unix}} \tab convert line endings\cr
#' \code{\link{download}} \tab download file\cr
#' \code{\link{enc}} \tab file encoding\cr
#' \code{\link{file.encoding}} \tab examine file encoding\cr
#' \code{\link{latin1.to.utf8}} \tab convert file encoding\cr
#' \code{\link{line.endings}} \tab examine line endings\cr
#' \code{\link{process.bib}} \tab read and process metadata\cr
Expand Down
7 changes: 4 additions & 3 deletions R/latin1.to.utf8.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
#'
#' @param file a filename.
#' @param force whether to perform the conversion even if the current file
#' encoding cannot be verified with \code{\link{enc}}. Not recommended.
#' encoding cannot be verified with \code{\link{file.encoding}}. Not
#' recommended.
#'
#' @note
#' In TAF, text files that have non-ASCII characters must be encoded as UTF-8.
#'
#' @seealso
#' \code{\link{iconv}} converts the encoding of a string.
#'
#' \code{\link{enc}} examines the encoding of a file.
#' \code{\link{file.encoding}} examines the encoding of a file.
#'
#' \code{\link{icesTAF-package}} gives an overview of the package.
#'
Expand All @@ -26,7 +27,7 @@

latin1.to.utf8 <- function(file, force=FALSE)
{
if(!isTRUE(enc(file)=="latin1") && !force)
if(!isTRUE(file.encoding(file)=="latin1") && !force)
{
warning("could not verify that file is 'latin1' encoded, nothing done")
return(invisible(NULL))
Expand Down
2 changes: 1 addition & 1 deletion R/line.endings.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#' String indicating the line endings: \code{"Dos"} or \code{"Unix"}.
#'
#' @seealso
#' \code{\link{enc}} examines the encoding of a file.
#' \code{\link{file.encoding}} examines the encoding of a file.
#'
#' \code{\link{dos2unix}} and \code{\link{unix2dos}} convert line endings.
#'
Expand Down
2 changes: 1 addition & 1 deletion R/utf8.to-latin1.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

utf8.to.latin1 <- function(file, force=FALSE)
{
if(!isTRUE(enc(file)=="UTF-8") && !force)
if(!isTRUE(file.encoding(file)=="UTF-8") && !force)
{
warning("could not verify that file is 'UTF-8' encoded, nothing done")
return(invisible(NULL))
Expand Down
17 changes: 9 additions & 8 deletions man/enc.Rd → man/file.encoding.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/icesTAF-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions man/latin1.to.utf8.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/line.endings.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 212387a

Please sign in to comment.