UrlDecoder.decodeCharacter

Extracts a single character from the specified position in the passed string, which is expected to be the index of a character preceded by a '%'. source[pos .. $] is scanned to see if they represent an encoded character in either the RFC 2396 escape format (%XX) or the non-standard escape format (%uXXXX) or if they should represent a '%' (%%).

(See: http://en.wikipedia.org/wiki/Percent-encoding)

On success the extracted character is written as utf8 into the provided output buffer and pos is increased to the index right after the last consumed character in source. On failure pos remains unchanged.

class UrlDecoder
static
decodeCharacter
out (slice) { assert (slice.ptr is dst.ptr, typeof(this).stringof ~ ".decodeCharacter: bad returned slice"); assert (pos <= source.length, typeof(this).stringof ~ ".decodeCharacter (out): offset out of array bounds"); }

Parameters

dst mstring

string buffer to receive decoded characters

source cstring

character string to decode a character from; may be empty or null which will result in failure

pos size_t

position in source

Return Value

Type: mstring

a slice to the UTF-8 representation of the decoded character in dst on success or an empty string on failure. The returned string is guaranteed to slice dst from dst[0].

Meta