# NOT RUN {
# `content-type` header is mostly used to look up charset and adjust encoding
parser_dcf <- function(...) {
function(value, content_type = "text/x-dcf", ...) {
charset <- get_character_set(content_type)
value <- rawToChar(value)
Encoding(value) <- charset
read.dcf(value, ...)
}
}
# Could also leverage existing parsers
parser_dcf <- function(...) {
parser_read_file(function(tmpfile) {
read.dcf(tmpfile, ...)
})
}
# Register the newly created parser
# }
# NOT RUN {
register_parser("dcf", parser_dcf, fixed = "text/x-dcf")
# }
Run the code above in your browser using DataLab