[R-gregmisc-users] SF.net SVN: r-gregmisc:[1813] trunk/gtools
Brought to you by:
warnes
From: <ar...@us...> - 2014-04-18 18:11:23
|
Revision: 1813 http://sourceforge.net/p/r-gregmisc/code/1813 Author: arnima Date: 2014-04-18 18:11:20 +0000 (Fri, 18 Apr 2014) Log Message: ----------- Main arg is 'x' like showNonASCII(x), preformatted notes instead of verb Modified Paths: -------------- trunk/gtools/R/ASCIIfy.R trunk/gtools/man/ASCIIfy.Rd Modified: trunk/gtools/R/ASCIIfy.R =================================================================== --- trunk/gtools/R/ASCIIfy.R 2014-04-17 19:05:11 UTC (rev 1812) +++ trunk/gtools/R/ASCIIfy.R 2014-04-18 18:11:20 UTC (rev 1813) @@ -1,4 +1,4 @@ -ASCIIfy <- function(string, bytes=2, fallback="?") +ASCIIfy <- function(x, bytes=2, fallback="?") { bytes <- match.arg(as.character(bytes), 1:2) convert <- function(char) # convert to ASCII, e.g. "z", "\xfe", or "\u00fe" @@ -23,13 +23,13 @@ return(ascii) } - if(length(string) > 1) + if(length(x) > 1) { - sapply(string, ASCIIfy, bytes=bytes, fallback=fallback, USE.NAMES=FALSE) + sapply(x, ASCIIfy, bytes=bytes, fallback=fallback, USE.NAMES=FALSE) } else { - input <- unlist(strsplit(string,"")) # "c" "a" "f" "<\'e>" + input <- unlist(strsplit(x,"")) # "c" "a" "f" "<\'e>" output <- character(length(input)) # "" "" "" "" for(i in seq_along(input)) output[i] <- convert(input[i]) # "c" "a" "f" "\\u00e9" Modified: trunk/gtools/man/ASCIIfy.Rd =================================================================== --- trunk/gtools/man/ASCIIfy.Rd 2014-04-17 19:05:11 UTC (rev 1812) +++ trunk/gtools/man/ASCIIfy.Rd 2014-04-18 18:11:20 UTC (rev 1813) @@ -6,10 +6,10 @@ single-byte (\samp{\x00}) or two-byte (\samp{\u0000}) codes. } \usage{ -ASCIIfy(string, bytes = 2, fallback = "?") +ASCIIfy(x, bytes = 2, fallback = "?") } \arguments{ - \item{string}{a character vector, possibly containing non-ASCII + \item{x}{a character vector, possibly containing non-ASCII characters.} \item{bytes}{either \code{1} or \code{2}, for single-byte (\samp{\x00}) or two-byte (\samp{\u0000}) codes.} @@ -23,7 +23,7 @@ \author{Arni Magnusson \email{ar...@ha...}} \note{ To render single backslashes, use these or similar techniques: - \verb{ + \preformatted{ write(ASCIIfy(x), "file.txt") cat(paste(ASCIIfy(x), collapse="\n"), "\n", sep="")} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |