vibe.d beta banner
get vibe.d
0.7.30

Function parseURLEncodedForm

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

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.

Prototype

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

Example

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");
Authors

Sönke Ludwig, Jan Krüger

Copyright

© 2012-2014 RejectedSoftware e.K.

License

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