Skip to main content

strings

Function strings 

Source
pub fn strings(
    texts: &[&str],
    std: Std,
    gnu: bool,
    target: &TargetInfo,
) -> Result<StringLiteral, LiteralError>
Expand description

Converts a run of adjacent string literals into the one literal they are.

The encoding of the result is the prefixed one when any of them is prefixed, so L"a" "b" and "a" L"b" are both wide, and two different prefixes in one run is an error rather than a choice. That is measured on gcc 13.3, which puts it exactly that way: “unsupported non-standard concatenation of string literals”.

The bodies are read in the encoding of the whole run rather than each in its own, which matters for a character rather than an escape: the accented letter in L"a" "e-acute" is one wide element and not the two bytes it would have been on its own.

§Errors

LiteralError, for a spelling that is not a string literal, a run mixing two prefixes, or an escape that is not one.