showNonASCII {tools}R Documentation

Highlight non-ASCII characters

Description

This function prints elements of a character vector which contain non-ASCII bytes, printing such bytes as a escape like <fc>.

Usage

showNonASCII(x)

Arguments

x a character vector.

Details

This was originally written to help detect non-portable text in files in packages.

It prints all lines of the files which contain non-ASCII characters, preceded by the line number and with non-ASCII bytes highlighted via iconv(sub = "byte").

Value

The elements of x containing non-ASCII characters will be returned invisibly.

Examples

out <- c(
"fa\xE7ile test of showNonASCII():",
"\\details{",
"   This is a good line",
"   This has an \xfcmlaut in it.",
"   OK again.",
"}")
f <- tempfile()
cat(out, file = f, sep = "\n")

showNonASCII(readLines(f))
unlink(f)

[Package tools version 2.11.0 Index]