vibe.d beta banner
get vibe.d

Asynchronous I/O that doesn’t get in your way, written in D

Function parseURLEncodedForm

Parses a URL encoded form and stores the key/value pairs.

void parseURLEncodedForm (
  string str,
  ref DictionaryList!(string,true,16L,false) params
) @safe;

Writes to the FormFields the key-value map associated to an "application/x-www-form-urlencoded" MIME formatted string, ie. all '+' characters are considered as ' ' spaces.


This example demonstrates parsing using all known form separators, it builds a key-value map into the destination FormFields

FormFields dst;
parseURLEncodedForm("a=b;c;dee=asd&e=fgh&f=j%20l", dst);
assert("a" in dst && dst["a"] == "b");
assert("c" in dst && dst["c"] == "");
assert("dee" in dst && dst["dee"] == "asd");
assert("e" in dst && dst["e"] == "fgh");
assert("f" in dst && dst["f"] == "j l");

Sönke Ludwig, Jan Krüger


© 2012-2014 Sönke Ludwig


Subject to the terms of the MIT license, as written in the included LICENSE.txt file.