From 79eed1b223014d2ba7e67cbb29c7e1cbf9b74530 Mon Sep 17 00:00:00 2001 From: Davis Vaughan Date: Wed, 25 Sep 2024 15:10:06 -0400 Subject: [PATCH] See if `&str` to `RObject` loses encoding --- crates/ark/src/data_explorer/format.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/crates/ark/src/data_explorer/format.rs b/crates/ark/src/data_explorer/format.rs index 696dc17a9..25cbd61f5 100644 --- a/crates/ark/src/data_explorer/format.rs +++ b/crates/ark/src/data_explorer/format.rs @@ -439,6 +439,8 @@ impl Into for FormattedValue { #[cfg(test)] mod tests { + use harp::utils::r_envir_set; + use super::*; use crate::test::r_test; @@ -751,11 +753,18 @@ mod tests { ]); options.max_value_length = 1000; - let _ = harp::parse_eval_global(r#"x <- c("ボルテックス")"#).unwrap(); - let data = harp::parse_eval_global(r#"Encoding(x)"#).unwrap(); + let text = RObject::from(r#"x <- c("ボルテックス")"#); + unsafe { r_envir_set("text", text.sexp, R_GlobalEnv) }; + let data = harp::parse_eval_global(r#"Encoding(text)"#).unwrap(); let data = String::try_from(data).unwrap(); - let _ = harp::parse_eval_global(r#"rm(x)"#).unwrap(); + let _ = harp::parse_eval_global(r#"rm(text)"#).unwrap(); assert_eq!(data, "UTF-8".to_string()); + + // let _ = harp::parse_eval_global(r#"x <- c("ボルテックス")"#).unwrap(); + // let data = harp::parse_eval_global(r#"Encoding(x)"#).unwrap(); + // let data = String::try_from(data).unwrap(); + // let _ = harp::parse_eval_global(r#"rm(x)"#).unwrap(); + // assert_eq!(data, "UTF-8".to_string()); // let formatted = format_column(data.sexp, &options); // assert_eq!(formatted, vec![ColumnValue::FormattedValue( // "ボルテックス".to_string()