       "a str%69ng"
 
   """
-  @spec encode(binary, (byte -> boolean)) :: binary
+  @spec encode(binary, (byte -> as_boolean(term))) :: binary
   def encode(string, predicate \\ &char_unescaped?/1)
       when is_binary(string) and is_function(predicate, 1) do
-    for <<char <- string>>, into: "", do: percent(char, predicate)
-  end
-
-  @doc """
-  Encodes a string as "x-www-form-urlencoded".
+    for <<byte <- string>>, into: "", do: percent(byte, predicate)
+  end
+
+  @doc """
+  Encodes `string` as "x-www-form-urlencoded".
 
   ## Example
 

  values are URL encoded as per `encode_www_form/1`.

  Keys and values can be any term that implements the `String.Chars`
  protocol, except lists which are explicitly forbidden.

  ## Examples


      iex> URI.to_string(%URI{scheme: "foo", host: "bar.baz"})
      "foo://bar.baz"

  Note that when creating this string representation, the `:authority` value will be
  used if the `:host` is `nil`. Otherwise, the `:userinfo`, `:host`, and `:port` will
  be used.

      iex> URI.to_string(%URI{authority: "foo@example.com:80"})
