Repository navigation
Remove dependency on LEVELS() - #1728
Conversation
b9b2616 to
0e1f8a8
Compare
|
I had to remove the tests for "unknown" encodings, i.e. for strings that are unmarked. The new API Davis, you added these tests in #1187. Do you have a good sense of how important this case is? I'm not sure how this arises in practice. Also I would expect edge cases to be less common in general now that Windows supports UTF-8. |
0e1f8a8 to
c0b056f
Compare
c0b056f to
83746c1
Compare
There was a problem hiding this comment.
We determined the one place this is actually used right now is in rlang's chr_detect_dups() function here
Line 228 in 23f0f30
Which is used by names_as_unique()
Line 49 in 23f0f30
Which is a common name repair strategy in the tidyverse.
Since no tests failed we determined this is probably going to work fine.
It is also worth noting that this is not currently used in vctrs right now. We did do the work to expose this in the rlang C API as an rlang callable, but we never went back and updated vctrs to use it (instead it uses its own local copy of a similar function).
Lastly, here is the main change:
The one case Rf_charIsUTF8 seems to be different for us is when:
- String is not "marked" as UTF8
- But
utf8localeis set totrue
In this case we previously assumed it was not UTF8 because it was "unknown" to us and we can't access utf8locale
But R can access utf8locale so I guess it assumes that if the string is not marked as anything and not NA and utf8locale is set, then it must be UTF8
This case is probably quite rare, and the only difference in behavior is that we used to call Rf_translateCharUTF8() on these "unknown" strings, but R seems to think they are UTF8 anyways, so that was probably already a no-op in terms of actual behavior (possibly it would add the UTF8 marking, but it probably didn't change the underlying bytes).
Closes #1726