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

gnr_resolve breaks when there is multibyte characters #904

Open
zachary-foster opened this issue Dec 1, 2022 · 2 comments
Open

gnr_resolve breaks when there is multibyte characters #904

zachary-foster opened this issue Dec 1, 2022 · 2 comments

Comments

@zachary-foster
Copy link
Collaborator

For example:

library(taxize)
gnr_resolve("Euphorbia \xd7 lomi")
#> Error in substring(x, 2): invalid multibyte string at '<d7> lomi'

Created on 2022-11-30 with reprex v2.0.2

Can be identified before hand using validEnd. Would be nice to just delete those characters and proceed with a warning

@salix-d
Copy link
Contributor

salix-d commented Mar 6, 2023

You can encode the input to UTF-8 with enc2utf8().

> taxize::gnr_resolve(enc2utf8("Euphorbia \xd7 lomi"))
# A tibble: 762 × 5
   user_supplied_name  submitted_name      matched_name                   data_source_title           score
 * <chr>               <chr>               <chr>                          <chr>                       <dbl>
 1 Euphorbia <d7> lomi Euphorbia <d7> lomi Euphorbia L.                   Catalogue of Life Checklist  0.75
 2 Euphorbia <d7> lomi Euphorbia <d7> lomi Euphorbia                      Wikispecies                  0.75
 3 Euphorbia <d7> lomi Euphorbia <d7> lomi Euphorbia sect. Chamaesyce     Wikispecies                  0.75
 4 Euphorbia <d7> lomi Euphorbia <d7> lomi Euphorbia sect. Alectoroctonum Wikispecies                  0.75
 5 Euphorbia <d7> lomi Euphorbia <d7> lomi Euphorbia sect. Euphorbia      Wikispecies                  0.75
 6 Euphorbia <d7> lomi Euphorbia <d7> lomi Euphorbia sect. Monadenium     Wikispecies                  0.75
 7 Euphorbia <d7> lomi Euphorbia <d7> lomi Euphorbia sect. Cubanthus      Wikispecies                  0.75
 8 Euphorbia <d7> lomi Euphorbia <d7> lomi Euphorbia sect. Lathyris       Wikispecies                  0.75
 9 Euphorbia <d7> lomi Euphorbia <d7> lomi Euphorbia sect. Lagascae       Wikispecies                  0.75
10 Euphorbia <d7> lomi Euphorbia <d7> lomi Euphorbia sect. Holophyllum    Wikispecies                  0.75
# … with 752 more rows
# ℹ Use `print(n = ...)` to see more rows

@zachary-foster
Copy link
Collaborator Author

Thanks for the tip!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants