Skip to content

Commit

Permalink
See if &str to RObject loses encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
DavisVaughan committed Sep 25, 2024
1 parent a40e2e6 commit 79eed1b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions crates/ark/src/data_explorer/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ impl Into<String> for FormattedValue {

#[cfg(test)]
mod tests {
use harp::utils::r_envir_set;

use super::*;
use crate::test::r_test;

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 79eed1b

Please sign in to comment.