Convert Strings Between Given Encodings
These functions convert strings between encodings.
They aim to replace R's
They are not only faster, but also much more portable - they
work in the same manner on all platforms.
stri_encode(str, from = NULL, to = NULL, to_raw = FALSE)
stri_conv(str, from = NULL, to = NULL, to_raw = FALSE)
a character vector, a raw vector, or a list of
rawvectors to be converted
""for the default encoding or internal encoding marks' usage (see Details); otherwise, a single string with encoding name, see
""for default encoding (see
stri_enc_get), or a single string with encoding name
a single logical value; indicates whether a list of raw vectors rather than a character vector should be returned
stri_conv is an alias for
str is a character vector
from is either missing,
then the declared encodings are used
stri_enc_mark) -- in such a case
strings are disallowed.
Otherwise, the internal encoding declarations are ignored and
a converter selected via
from is used.
str is a
or a list of raw vectors,
we assume that the input encoding is the current default encoding
as given by
to_raw=FALSE, the output
strings have always marked encodings according to the target converter
used (as specified by
to) and the current default Encoding
bytes in all other cases).
Note that some issues might occur if
to indicates, e.g,
UTF-16 or UTF-32, as the output strings may have embedded NULs.
In such cases, please use
to_raw=TRUE and consider
specifying a byte order marker (BOM) for portability reasons
UTF-32 which automatically
adds the BOMs).
is a clever substitute for
In the current version of stringi, if an incorrect code point is found on input, it is replaced by the default (for that target encoding) substitute character. Also, in such a case a warning is generated.
then a character vector with encoded strings (and appropriate
encoding marks) is returned.
Otherwise, a list of raw vectors is produced.
Conversion -- ICU User Guide, http://userguide.icu-project.org/conversion
Converters -- ICU User Guide, http://userguide.icu-project.org/conversion/converters (technical details)