Skip to main content

Module encoding

Module encoding 

Source
Expand description

Encoding / locale probing utilities.

This module exists mainly for debugging + experiments around R’s string encodings. R’s runtime has both:

  • per-CHARSXP encoding tags (UTF-8 / Latin-1 / bytes / native)
  • global/locale-level settings (native encoding, UTF-8 locale flags)

§Availability

The global signals are non-API (from Defn.h) and require the nonapi feature. Only the locale flags R’s shared library exports are read (utf8locale, mbcslocale, known_to_be_latin1); the hidden ones (known_to_be_utf8, latin1locale, R_nativeEncoding) must not even be referenced — an eager data relocation against a hidden symbol aborts dyn.load of the whole package (see sys::nonapi_encoding).

miniextendr_encoding_init() is not called by package_init; it exists for debugging and for standalone Rust applications embedding R.

Structs§

REncodingInfo
Cached snapshot of R’s encoding / locale state at init time.

Statics§

ENCODING_INFO 🔒

Functions§

encoding_info
Return the cached encoding info (if miniextendr_encoding_init() has run).
miniextendr_assert_utf8_locale
Assert that R’s locale is UTF-8.
miniextendr_encoding_init
Initialize / snapshot R’s encoding state.