stringi icon indicating copy to clipboard operation
stringi copied to clipboard

Encoding sleuthing function

Open hadley opened this issue 8 years ago • 1 comments

Sometimes you know what a character should be, and you know how it's stored in a file, and you want to figure out what encoding it might have been (e.g. https://github.com/hadley/readr/issues/252). It would be helpful to have something to help automate the search, e.g.

x <- "Ü"
encs <- names(stri_enc_list())
conv <- lapply(encs, function(to) stri_conv(x, "UTF-8", to, to_raw = TRUE)[[1]])
names(conv) <- encs
Filter(function(x) identical(x[[1]], charToRaw("\x86")), conv)

hadley avatar Sep 21 '15 14:09 hadley

good idea, thanks

gagolews avatar Oct 01 '15 09:10 gagolews