A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
a11::percent Namespace Reference

Functions

int HexDigit (char one)
 The value 0-15 of a hex digit, either case, or -1 if one is not one.
 
std::string Decode (std::string_view value, bool plus_is_space=false)
 Percent-decodes value, leaving anything malformed as it stands.
 
absl::StatusOr< std::string > DecodeStrict (std::string_view value, std::string_view what)
 Percent-decodes value, or says why it cannot be decoded.
 
std::string Encode (std::string_view value)
 Percent-encodes everything outside RFC 3986's unreserved set.
 

Function Documentation

◆ Decode()

std::string a11::percent::Decode ( std::string_view  value,
bool  plus_is_space = false 
)
inline

Percent-decodes value, leaving anything malformed as it stands.

The lenient posture: an undecodable % is passed through as itself rather than dropped, so a malformed query gives a "no such thing" answer instead of a silently different one, and a propagator keeps a baggage value it cannot read rather than losing it.

Parameters
valueText to decode.
plus_is_spaceMap + to a space, as application/x-www-form-urlencoded does. Off for a URL path or a baggage value, where + is literal.

◆ DecodeStrict()

absl::StatusOr< std::string > a11::percent::DecodeStrict ( std::string_view  value,
std::string_view  what 
)
inline

Percent-decodes value, or says why it cannot be decoded.

The strict posture, for text where a malformed escape means the caller got the input wrong and should hear about it rather than connect somewhere slightly different – a URL carrying credentials, for instance.

Parameters
valueText to decode.
whatNames the input in the error, e.g. "Redis URL".

◆ Encode()

std::string a11::percent::Encode ( std::string_view  value)
inline

Percent-encodes everything outside RFC 3986's unreserved set.

◆ HexDigit()

int a11::percent::HexDigit ( char  one)
inline

The value 0-15 of a hex digit, either case, or -1 if one is not one.