Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse UTF-8 strings on Windows #94

Merged
merged 5 commits into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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