[Rd] special latin1 do not print as glyphs in current devel on windows
Daniel Possenriede
possenriede at gmail.com
Tue Aug 1 12:33:47 CEST 2017
Sorry, I should have included my console output, obviously. So here we go:
Wrong UTF-8 escapes with using print in v3.5.0 devel:
# R Under development (unstable) (2017-07-30 r73000) -- "Unsuffered
Consequences"
# Platform: x86_64-w64-mingw32/x64 (64-bit)
> x <- c("€", "–", "‰")
> Encoding(x)
[1] "latin1" "latin1" "latin1"
> print(x)
[1] "\u0080" "\u0096" "\u0089"
Same output with enc2utf8()
> enc2utf8(x)
[1] "\u0080" "\u0096" "\u0089"
With iconv() the result is as expected.
> iconv(x, to = "UTF-8")
[1] "€" "–" "‰"
The second problem IMO is that encoding markers get lost with the enc2*
functions
> x_utf8 <- enc2utf8(x)
> Encoding(x_utf8)
[1] "UTF-8" "UTF-8" "UTF-8"
> x_nat <- enc2native(x_utf8)
> Encoding(x_nat)
[1] "unknown" "unknown" "unknown"
This is not the case with iconv()
> x_iutf8 <- iconv(x, to = "UTF-8")
> Encoding(x_iutf8)
[1] "UTF-8" "UTF-8" "UTF-8"
> x_inat <- iconv(x_iutf8, from = "UTF-8")
> Encoding(x_inat)
[1] "latin1" "latin1" "latin1"
[[alternative HTML version deleted]]
More information about the R-devel
mailing list