-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
band aid for characters with unknown encodings
closes #12
- Loading branch information
1 parent
7c81835
commit a7e97dd
Showing
6 changed files
with
34 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#' Attempt to transform chars in encodings we don't understand, rather than crash crayon. | ||
#' @author Miles McBain | ||
sanitise_col <- function(col) { | ||
sanitise_text( | ||
ifelse(!validEnc(col), stringi::stri_trans_general(col, "latin-ascii"), col) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# invalid encodings are handled | ||
|
||
Code | ||
paint(df) | ||
Output | ||
data.frame [1, 3] | ||
bad chr 23�C | ||
good chr dummy | ||
the_worst chr 2015 President and Vice-Chancellor�s Alumni S~ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
test_that("invalid encodings are handled", { | ||
df <- data.frame( | ||
bad = "23\xbfC", | ||
good = "dummy", | ||
the_worst = "2015 President and Vice-Chancellor\x92s Alumni Scholarship Appeal" | ||
) | ||
|
||
expect_snapshot(paint(df)) | ||
}) |