Skip to main content

Crate nwnrs_encoding

Crate nwnrs_encoding 

Source
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 String values
  • 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§

EncodingConversionError
An error returned when a text conversion fails for a configured encoding.
NativeEncodingError
An error returned when the native system encoding cannot be determined.
UnknownEncodingError
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.