charport 0.2.0 (2026-11-06)
CRAN release: 2026-11-06
- New
charpackclass: a compact ALTREP character vector whose strings live in one R raw vector, for many short vectors. AReaderreaches any element directly, without allocating.as_charpack()converts to one andis_charpack()tests for one. In C++,charpack::from_store()copies a finishedcharvec::Storeinto one, so a producer can build with thecharvecbuilders and choose the class at the end. Reading an element through ordinary R access materializes the wholecharpack; aReaderkeeps it packed, and so do vector subsets such asx[i], which return a newcharpack. -
charvec::alloc_na(),charvec::get_store()andcharvec::Writerfill acharvecin place after it is created. - On R >= 4.6,
Readernow handles basewrap_stringALTREP without materialization. -
charport_materialize()also materializes acharpack. - Fix
x[i]on acharvecreturningNAfor a real index betweenlength(x)andlength(x) + 1, instead of the last element. - A filled
charpackserializes in its compact form, likecharvec, without materializing; on a little-endian host its raw vector is written and read back without a copy. Both write little-endian on every host; big-endiancharvecstates from earlier versions still load. - Serialization is now safe across locales. A
charvecorcharpackwith native-encoded strings is saved in packed form only in a UTF-8 locale; elsewhere it is saved as an ordinary character vector, so R converts its strings on reading, and the source stays packed. Native strings in a packed state read outside a UTF-8 locale are marked UTF-8.charvecstates are now version 2; version 1 states from 0.1 still load, with native strings read as the current locale’s, as before. - New C function
charport_native_is_utf8()(C++:charport::native_is_utf8()) reports whether R currently reads native strings as UTF-8, followingSys.setlocale(). -
Readernow calls a registered class’initfirst, and otherwise falls back toSTRING_PTR_RO.