Comments (3)
I am afraid this is too specific to be included in stringi
.
Perhaps an easier solution: ?
x <- "test 123 ↓ęœß→óęœ©œ©ęπœęπœ©œπą"
x <- unique(unlist(stringi::stri_enc_toutf32(x)))
x <- x[x>127]
stringi::stri_enc_fromutf32(x)
## [1] "↓ęœß→ó©πą"
from stringi.
-
Function stri_enc_toutf32 does indeed the conversion directly. Unfortunately, I am not an expert in the package stringi.
- it would break if an UTF-64 was introduced: but then again this should be an internal implementation detail inside another function and would be therefore invisible to the end user;
-
Documentation/Examples with stringi::stri_escape_unicode
- for the last solution: I would include an extra example mentioning how to convert back to Unicode code points or how to escape the characters with stri_escape_unicode;
- alternatively, the function could have an option to either return the code-points or the characters;
- Utility
I have frequently encountered this situation: both when trying to extract information from articles on Pubmed, as well as from various reports (e.g. Lab-reports). There are probably sufficiently large communities involved in both types of operations, but having only rudimentary understanding of string encodings. If the (manual) cleaning is too time-consuming, then the most common options are:
- to exclude those inputs, or to delete any non-ASCII characters (if the user understands a little bit more about ASCII);
- both approaches are quite sub-optimal: better tools can come in handy for many simple users;
from stringi.
So, you probably mean:
x <- "test 123 ↓ęœß→óęœ©œ©ęπœęπœ©œπą"
x <- unique(unlist(stringi::stri_enc_toutf32(x)))
x <- as.list(x[x>127])
stringi::stri_escape_unicode(stringi::stri_enc_fromutf32(x))
## [1] "\\u2193" "\\u0119" "\\u0153" "\\u00df" "\\u2192" "\\u00f3" "\\u00a9" "\\u03c0" "\\u0105"
from stringi.
Related Issues (20)
- stri_split_boundaries() returns slightly different tokens when the ICU rules are supplied HOT 3
- [Feature] Convert String to Code Points HOT 2
- Unable to install stringi in R 4.3 HOT 10
- install issue, no internet HOT 2
- Behavior of `stri_sub()` when `from = 0` HOT 2
- Cannot install stringi on linux (CENTOS 7) machine HOT 1
- installation of package 'stringi' had non-zero exit status HOT 2
- Fails to build with clang on Windows HOT 2
- Calling stringi C functions without Rcpp HOT 2
- Installation fails on Apple Silicon M1
- Possibly unintentional breakage on 32 bit Windows and R 3.6 HOT 7
- PKG_CPPFLAGS should take precendence over CPPFLAGS in configure
- stringi needs compilation HOT 1
- Feature request: allow counting blank space at end of last line in `stri_wrap()`
- Feature request: stri_replace_*_regex pattern is a column name, replacement a $1 HOT 6
- Compilation errors on R-devel HOT 3
- Compilation failed after loading my .Rprofile HOT 1
- The stringi installation error occurred because the Linux system was upgraded to the latest icu-75.1-1 HOT 1
- "stack imbalance" warning when use `stri_encode` in 0-row tibble HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stringi.