R/isGB18030.R

Defines functions isGB18030

Documented in isGB18030

##' Indicate whether the encoding of input string is GB18030.
##' 
##' @title Indicate whether the encoding of input string is GB18030.
##' @param string A character vector.
##' @param combine Whether to combine all the strings.
##' @return Logical value.
##' @author Jian Li <\email{rweibo@@sina.com}>
##' @examples
##' isGB18030("hello")

isGB18030 <- function(string, combine = FALSE)
{
	string <- .verifyChar(string)
	if (length(string)  == 1) {
		OUT <- .C("CWrapper_encoding_isgb18030", 
				characters = as.character(string),  
				numres = 2L)
		OUT <- as.logical(OUT$numres)
	} else {
		if (combine) {
			OUT <- isGB18030(paste(string, collapse = ""))
		} else {
			OUT <- as.vector(sapply(string, isGB18030))
		}
	}
	return(OUT)
}

Try the tmcn package in your browser

Any scripts or data that you put into this service are public.

tmcn documentation built on Aug. 4, 2019, 3 p.m.