Skip to content

Commit

Permalink
[misc] array formulas might contain unicode strings
Browse files Browse the repository at this point in the history
  • Loading branch information
JanMarvin committed Jan 2, 2025
1 parent 5d062ca commit 09357c0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/openxlsx2_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ inline SEXP wrap(const std::vector<xml_col> &x) {
if (!x[ii].c_ph.empty()) c_ph[i] = Rcpp::String(x[ii].c_ph);
if (!x[ii].c_vm.empty()) c_vm[i] = std::string(x[ii].c_vm);
if (!x[ii].v.empty()) { // can only be utf8 if c_t = "str"
if (x[ii].c_t.empty()) v[i] = std::string(x[ii].v);
else v[i] = Rcpp::String(x[ii].v);
if (x[ii].c_t.empty() && x[ii].f_t.empty())
v[i] = std::string(x[ii].v);
else
v[i] = Rcpp::String(x[ii].v);
}
if (!x[ii].f.empty()) f[i] = Rcpp::String(x[ii].f);
if (!x[ii].f_t.empty()) f_t[i] = std::string(x[ii].f_t);
Expand Down
2 changes: 1 addition & 1 deletion src/write_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ pugi::xml_document xml_sheet_data(Rcpp::DataFrame row_attr, Rcpp::DataFrame cc)
cell.append_child("v").append_attribute("xml:space").set_value("preserve");
cell.child("v").append_child(pugi::node_pcdata).set_value(" ");
} else {
if (std::string(cc_c_t[i]).empty())
if (std::string(cc_c_t[i]).empty() && std::string(cc_f_t[i]).empty())
cell.append_child("v").append_child(pugi::node_pcdata).set_value(std::string(cc_v[i]).c_str());
else
cell.append_child("v").append_child(pugi::node_pcdata).set_value(to_string(cc_v[i]).c_str());
Expand Down

0 comments on commit 09357c0

Please sign in to comment.