| 1 |
UNICODE_WARNING <- |
| 2 |
'Your code contains a unicode char which cannot be displayed in your |
| 3 |
current locale and R will silently convert it to an escaped form when the |
| 4 |
R kernel executes this code. This can lead to subtle errors if you use |
| 5 |
such chars to do comparisons. For more information, please see |
| 6 |
https://github.com/IRkernel/repr/wiki/Problems-with-unicode-on-windows' |
| 7 |
|
| 8 |
|
| 9 |
warn_unicode_on_windows <- function(code, warn) { |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
if (.Platform$OS.type == 'windows') { |
| 14 |
|
| 15 |
code <- gsub('^\\s+|\\s+$', '', code) |
| 16 |
real_len <- nchar(code) |
| 17 |
r_len <- nchar(paste(capture.output(cat(code)), collapse = '\n')) |
| 18 |
if (real_len != r_len) warn(UNICODE_WARNING) |
| 19 |
} |
| 20 |
} |