diff --git a/CHANGELOG.md b/CHANGELOG.md index 644c4b04..bbb790c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,10 @@ #> [1] -1 ``` +### Bug fixes + +* `r_print!()` and `r_eprint!()` now can print strings containing `%`. + ## [v0.6.3] (2024-05-05) ### New features diff --git a/src/io.rs b/src/io.rs index 5eaee360..621419a6 100644 --- a/src/io.rs +++ b/src/io.rs @@ -7,7 +7,7 @@ pub(crate) const LINEBREAK: [c_char; 2] = [b'\n' as _, b'\0' as _]; pub fn r_print(msg: &str, linebreak: bool) { if !msg.is_empty() { // ignore error - let _ = r_stdout().write_all(msg.as_bytes()); + let _ = r_stdout().write_all(msg.replace('%', "%%").as_bytes()); } unsafe { @@ -20,7 +20,7 @@ pub fn r_print(msg: &str, linebreak: bool) { pub fn r_eprint(msg: &str, linebreak: bool) { if !msg.is_empty() { // ignore error - let _ = r_stderr().write_all(msg.as_bytes()); + let _ = r_stderr().write_all(msg.replace('%', "%%").as_bytes()); } unsafe {