Skip to content

Commit

Permalink
Merge pull request #94 from ateucher/issue90
Browse files Browse the repository at this point in the history
Parse UTF-8 strings on Windows
  • Loading branch information
dcooley authored Mar 3, 2022
2 parents fc8359b + 52ef035 commit 0550dbe
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
8 changes: 4 additions & 4 deletions inst/include/geojsonsf/geojson/geojson_properties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ namespace geojson_properties {
properties.names() = property_keys;
std::vector< std::string > n = properties.names();
std::reverse( n.begin(), n.end() );
std::vector< std::string > sv( n.size() );
Rcpp::StringVector sv( n.size() );
R_xlen_t i;

for( i = 0; i < n.size(); ++i ) {
sv[i] = n[i];
std::string s = n[i];
sv[i] = Rcpp::String( s );
}
properties.names() = sv;

}

inline void get_property_keys(
Expand All @@ -108,7 +108,7 @@ namespace geojson_properties {
const R_xlen_t& row_index
) {
Rcpp::StringVector sv = sf[key];
sv[row_index] = value;
sv[row_index] = Rcpp::String( value );
sf[key] = sv;
}

Expand Down
6 changes: 6 additions & 0 deletions inst/tinytest/test-geojson_sf.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,9 @@
expect_true( is.logical( sf$b ) )
expect_true( is.character( sf$c ) )

## Issue 90
## UTF8-encoded strings
geojson <- enc2utf8('{"type":"Feature","geometry":{"type":"Point","coordinates":[7.624747,51.954044]},"properties":{"örtchen":"Münster"}}')
out <- geojson_sf( geojson )
expect_equal(out[1][[1]], "Münster")
expect_equal(names(out)[1], "örtchen")
5 changes: 5 additions & 0 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

using namespace Rcpp;

#ifdef RCPP_USE_GLOBAL_ROSTREAM
Rcpp::Rostream<true>& Rcpp::Rcout = Rcpp::Rcpp_cout_get();
Rcpp::Rostream<false>& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get();
#endif

// rcpp_df_to_geojson_atomise
Rcpp::StringVector rcpp_df_to_geojson_atomise(Rcpp::DataFrame& df, Rcpp::StringVector& geometry_columns, int& digits, bool& factors_as_string);
RcppExport SEXP _geojsonsf_rcpp_df_to_geojson_atomise(SEXP dfSEXP, SEXP geometry_columnsSEXP, SEXP digitsSEXP, SEXP factors_as_stringSEXP) {
Expand Down

0 comments on commit 0550dbe

Please sign in to comment.