Skip to main content

encode_str_for_collation

Function encode_str_for_collation 

Source
pub fn encode_str_for_collation(
    value: &str,
    collation: Option<&Collation>,
) -> Vec<u8> 
Expand description

Transcode a Rust &str into single-byte VARCHAR bytes for the given collation.

  • UTF-8 collations (SQL Server 2019+) pass through as raw UTF-8 bytes.
  • Known non-UTF-8 LCIDs transcode via the matching encoding_rs codec.
  • Unknown or None collations fall back to Windows-1252 (Latin1_General_CI_AS).

When the encoding feature is disabled, characters ≤ 0xFF pass through as Latin-1 bytes and everything else becomes ?.