diff --git a/NAMESPACE b/NAMESPACE index 00b238f..59baacc 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -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) diff --git a/NEWS b/NEWS index 5b3b930..e5b0b28 100644 --- a/NEWS +++ b/NEWS @@ -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. diff --git a/R/enc.R b/R/file.encoding.R similarity index 87% rename from R/enc.R rename to R/file.encoding.R index 0c0151c..320fc6e 100644 --- a/R/enc.R +++ b/R/file.encoding.R @@ -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 @@ -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") diff --git a/R/icesTAF-package.R b/R/icesTAF-package.R index 4ebd947..1912da6 100644 --- a/R/icesTAF-package.R +++ b/R/icesTAF-package.R @@ -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 diff --git a/R/latin1.to.utf8.R b/R/latin1.to.utf8.R index f1e5fe5..b4db952 100644 --- a/R/latin1.to.utf8.R +++ b/R/latin1.to.utf8.R @@ -4,7 +4,8 @@ #' #' @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. @@ -12,7 +13,7 @@ #' @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. #' @@ -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)) diff --git a/R/line.endings.R b/R/line.endings.R index 46efd7e..7f867d6 100644 --- a/R/line.endings.R +++ b/R/line.endings.R @@ -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. #' diff --git a/R/utf8.to-latin1.R b/R/utf8.to-latin1.R index 02d67ef..b306413 100644 --- a/R/utf8.to-latin1.R +++ b/R/utf8.to-latin1.R @@ -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)) diff --git a/man/enc.Rd b/man/file.encoding.Rd similarity index 76% rename from man/enc.Rd rename to man/file.encoding.Rd index e74dbf6..6f9b30d 100644 --- a/man/enc.Rd +++ b/man/file.encoding.Rd @@ -1,17 +1,16 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/enc.R -\name{enc} -\alias{enc} +% Please edit documentation in R/file.encoding.R +\name{file.encoding} +\alias{file.encoding} \title{File Encoding} \usage{ -enc(file) +file.encoding(file) } \arguments{ \item{file}{a filename.} } \value{ -\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 @@ -31,8 +30,8 @@ In TAF, text files that have non-ASCII characters must be encoded as UTF-8. \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) } } @@ -42,5 +41,7 @@ enc(file.nlme) \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. } diff --git a/man/icesTAF-package.Rd b/man/icesTAF-package.Rd index 3a67f76..2872db4 100644 --- a/man/icesTAF-package.Rd +++ b/man/icesTAF-package.Rd @@ -69,7 +69,7 @@ data, methods, and results used in ICES assessments. \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 diff --git a/man/latin1.to.utf8.Rd b/man/latin1.to.utf8.Rd index dd2a8bb..bdda8df 100644 --- a/man/latin1.to.utf8.Rd +++ b/man/latin1.to.utf8.Rd @@ -13,7 +13,8 @@ utf8.to.latin1(file, force = FALSE) \item{file}{a filename.} \item{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.} } \description{ Convert file encoding between \verb{"latin1"} and \verb{"UTF-8"}. @@ -31,7 +32,7 @@ latin1.to.utf8("data.txt") \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. } diff --git a/man/line.endings.Rd b/man/line.endings.Rd index b7f61d4..38bb9a6 100644 --- a/man/line.endings.Rd +++ b/man/line.endings.Rd @@ -23,7 +23,7 @@ line.endings(file) } \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.