This library wants to put back the fun in working with URL-Encoded Strings.
- The
Pimp my library
pattern is use to make this extension possible. It is implemented usingvalue classes
to keep the overhead low. - The library is biased towards using
%20
to escape+
. - The library is biased towards
utf-8
. You can circumvent this though by supplying a different Encoding though as implicit parameter.
Import the implicits to get your strings pimped:
scala> import biz.neumann.url.NiceURLCodecs._
import biz.neumann.url.NiceURLCodecs._
scala> "ˈbalɐˌman".encode
res0: biz.neumann.url.NiceURLCodecs.URLEncodedString = %CB%88bal%C9%90%CB%8Cman
Using some other encoding:
scala> "ˈbalɐˌman".encode("latin1")
res1: biz.neumann.url.NiceURLCodecs.URLEncodedString = %3Fbal%3F%3Fman
scala> "ˈbalɐˌman".encode.decode
res1: String = ˈbalɐˌman
scala> "x%20x+x".decode
res3: String = x x x