pctEncodeTo

fnvoid pctEncodeTo(R)(string s, Component comp, ref R dst) @safe

Write percent-encoded representation of s for component comp to dst.

Leaves unreserved characters untouched and also leaves component-allowed reserved characters as-is; all other code points are UTF-8 encoded and emitted as %HH sequences.

This overload avoids intermediate string allocation by writing directly to an output range.

Parameters

sInput string to encode.
compURI component whose encoding rules apply.
dstOutput range that receives the encoded bytes.

Examples

import std.array : appender;
auto w = appender!string();
pctEncodeTo("a b+", Component.Query, w);
assert(w.data == "a%20b+"); // space encoded, '+' preserved in RFC mode