You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# This is the Byte Order Mark:bom<- as.raw(c(255, 254))
# This is the text.text<-"1\t2\n"# Converted to UTF-16LEtext_utf16<- iconv(text,from="UTF-8",to="UTF-16LE", toRaw=TRUE)[[1]]
# Write the BOM and the text to a filetmp_file_name<- tempfile()
fd<- file(tmp_file_name, "wb")
writeBin(bom, fd)
writeBin(text_utf16, fd)
close(fd)
# read the file and use iconv to convert it to UTF-8con<- file(tmp_file_name, "rb")
x<- readBin(con, "raw", n=100)
vroom::vroom(iconv(list(x), from="UTF-16LE", to="UTF-8", toRaw=TRUE), col_names=FALSE)
#> Observations: 1#> Variables: 2#> dbl [2]: X1, X2#> #> Call `spec()` for a copy-pastable column specification#> Specify the column types with `col_types` to quiet this message#> # A tibble: 1 x 2#> X1 X2#> <dbl> <dbl>#> 1 1 2
Created on 2019-06-20 by the reprex package (v0.3.0)
So we should basically be able to do this iconv conversion on the fly if given a multi-byte encoding.
The text was updated successfully, but these errors were encountered: