Expand description
§nwnrs-encoding
nwnrs-encoding is the workspace policy boundary for text encoding.
§Why This Crate Exists
NWN stores text in a non-UTF-8 encoding that varies by platform and language.
Without a central policy boundary, every format crate would embed its own
encoding assumptions and diverge silently. This crate makes the workspace
encoding policy explicit and gives all format crates a single place to
transcode NWN byte storage to and from Rust String values.
§Scope
- define the default NWN text encoding
- detect host-native encoding when needed
- expose conversion routines between NWN byte storage and Rust
Stringvalues - make encoding policy explicit instead of scattering it across format crates
The central operations are to_nwnrs_encoding, from_nwnrs_encoding,
to_native_encoding, and from_native_encoding.
§Public Surface
- provide a complete transcoding framework for arbitrary encodings
- own higher-level localization semantics
§See also
nwnrs-localization, which defines the language and string-reference vocabulary built on top of this encoding layer
Modules§
- prelude
- Common imports for consumers of this crate.
Structs§
- Encoding
Conversion Error - An error returned when a text conversion fails for a configured encoding.
- Native
Encoding Error - An error returned when the native system encoding cannot be determined.
- Unknown
Encoding Error - An error returned when an encoding label cannot be resolved.
Functions§
- clear_
native_ encoding - Clears any cached native encoding so it will be detected again on demand.
- detect_
system_ native_ encoding - Detects the process-native text encoding for the current platform.
- from_
native_ encoding - Decodes bytes using the current native system encoding.
- from_
nwnrs_ encoding - Decodes bytes using the current NWN encoding.
- get_
native_ encoding - Returns the configured or detected native system encoding.
- get_
native_ encoding_ name - Returns the canonical label for the native system encoding.
- get_
nwnrs_ encoding - Returns the encoding currently used for NWN text data.
- get_
nwnrs_ encoding_ name - Returns the canonical label for the current NWN text encoding.
- set_
native_ encoding - Overrides the detected native system encoding.
- set_
nwnrs_ encoding - Sets the encoding used for NWN text data.
- to_
native_ encoding - Encodes a string using the current native system encoding.
- to_
nwnrs_ encoding - Encodes a string using the current NWN encoding.